楼主: lpchxj
1767 5

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

  • 3关注
  • 5粉丝

已卖:437份资源

教授

56%

还不是VIP/贵宾

-

威望
0
论坛币
41 个
通用积分
8.9518
学术水平
6 点
热心指数
14 点
信用等级
1 点
经验
4143 点
帖子
310
精华
0
在线时间
2280 小时
注册时间
2006-12-3
最后登录
2025-4-24

楼主
lpchxj 发表于 2018-12-27 23:00:23 |AI写论文
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
拉您入交流群
GMT+8, 2025-12-27 06:01