楼主: lpchxj
1544 5

[编程问题求助] 如何依次将多个url放到copy的命令中 [推广有奖]

  • 3关注
  • 5粉丝

教授

54%

还不是VIP/贵宾

-

威望
0
论坛币
42 个
通用积分
10.1518
学术水平
6 点
热心指数
14 点
信用等级
1 点
经验
3623 点
帖子
309
精华
0
在线时间
2270 小时
注册时间
2006-12-3
最后登录
2024-8-26

50论坛币
我在stata中定义了一个变量url(字符串),里面包含有网址(url),
url
http://guba.eastmoney.com/news,szzs,795812396.html
http://guba.eastmoney.com/news,szzs,795606945.html
http://guba.eastmoney.com/news,szzs,795394754.html
http://guba.eastmoney.com/news,szzs,794650987.html
http://guba.eastmoney.com/news,szzs,795575875.html
我的问题是:如何依次将这个url放到copy的命令中,
即   copy "http://guba.eastmoney.com/news,szzs,795812396.html" "H:\test.txt",replace
然后copy "http://guba.eastmoney.com/news,szzs,795606945.html" "H:\test.txt",replace
依次逐个读入

我的url地址有很多,不能手工输入,请各位指导,多谢了!



最佳答案

songking 查看完整内容

levelsof url foreach x in `r(levels)'{ di "`x'" local name=substr("`x'",-14,9) copy "`x'" test_`name'.txt,replace }
关键词:字符串
沙发
songking 发表于 2018-12-27 23:00:24 |只看作者 |坛友微信交流群
levelsof url
foreach x  in `r(levels)'{
di "`x'"
local name=substr("`x'",-14,9)
copy "`x'"  test_`name'.txt,replace
}

使用道具

藤椅
lpchxj 发表于 2018-12-28 09:03:34 |只看作者 |坛友微信交流群
非常感谢您!@songking

使用道具

板凳
lpchxj 发表于 2018-12-28 11:06:12 |只看作者 |坛友微信交流群
songking 发表于 2018-12-27 23:00
levelsof url
foreach x  in `r(levels)'{
di "`x'"
再请教您:如果某一个链接无效,怎么样设置其自动进入到下一个链接?

使用道具

报纸
songking 发表于 2018-12-28 18:36:19 |只看作者 |坛友微信交流群
lpchxj 发表于 2018-12-28 11:06
再请教您:如果某一个链接无效,怎么样设置其自动进入到下一个链接?
levelsof url
foreach x  in `r(levels)'{
di "`x'"
local name=substr("`x'",-14,9)
cap copy "`x'"  test_`name'.txt,replace
}

使用道具

地板
紫藤萝之夏 在职认证  学生认证  发表于 2019-1-19 23:30:00 |只看作者 |坛友微信交流群
楼主,你的Url是如何定义的,可否告知代码?

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-10-6 19:42