中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-08 20:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [原创]批量智能下载网页图片[抛砖] 查看 4,190 回复 23
16 curl和sed的问题 发表于 2008-03-17 00:48 ·  中国 安徽 马鞍山 电信
中级用户
★★
拟谷盗
积分 312
发帖 108
注册 2007-01-21 11:36
19年会员
UID 77238
性别 男
状态 离线
curl "http://220.181.38.82/m?ct=134217728&tn=baidusg,不得不爱  &word=mp3,http://www.yantaiblog.net/UploadFiles/2007-7/aGhmbGtmbGsx.mp3,,&si=%B2%BB%B5%C3%B2%BB%B0%AE;;%C5%CB%E7%E2%B0%D8;;51913;;51913&lm=16777216"

curl: (3) illegal character in range specification at pos 132
总感觉curl在某些方面有很多缺陷,为何出现这样的情况?
有时 url中 有 & 字符时必需使用在 & 前加转义字符,而有些时候却不需要,为何?


curl http://list.mp3.baidu.com/topso/mp3topsong.html | sed "s/\x22/\xa/g;/baidump3/!d"

curl http://list.mp3.baidu.com/topso/mp3topsong.html | sed "s/\x22/\xa/g" | sed "/baidump3/!d"

这2个命令执行的结果为何不一样?
FLOSS
17 发表于 2008-03-17 13:53 ·  中国 浙江 杭州 电信
高级用户
★★
积分 537
发帖 219
注册 2007-08-04 09:43
19年会员
UID 94620
性别 男
来自 杭州--半山
状态 离线
总感觉curl在某些方面有很多缺陷,为何出现这样的情况?
有时 url中 有 & 字符时必需使用在 & 前加转义字符,而有些时候却不需要,为何?
--------------------------
1我想应该跟CMD.EXE语法分析有关,cmd碰到&它认为是一个语句的结束。


这2个命令执行的结果为何不一样?
--------------------------------------------
2。sed 是以行为单位进行读取数据的。大概过程是提取curl里的一行数据读取后的内容存放在pattern space。经过 sed "s/\x22/\xa/g" 处理后,貌似生成了多行,实际上它仍然存储在pattern space,作为一个未加工完的半成品,/baidump3/!d 再对其进行处理。
反正记住
sed对它输入的数据是采取一行行读的,输入可能是以管道,文件,进程中的通信等方式。
pattern space的内容是不会以 输入 那样对待的。

[ Last edited by junchen2 on 2008-3-17 at 01:54 PM ]
18 发表于 2008-03-18 16:24 ·  中国 甘肃 兰州 电信
金牌会员
★★★★
积分 4,103
发帖 1,744
注册 2006-01-20 13:00
20年会员
UID 49241
性别 男
来自 甘肃.临泽
状态 离线
像from提交的网页用 wget 和 curl 都可以解决,两个都试下就好了
19 发表于 2008-03-18 19:02 ·  中国 北京 海淀区 联通
银牌会员
★★★
积分 1,287
发帖 634
注册 2007-05-02 15:06
19年会员
UID 87277
性别 男
来自 cmd.exe
状态 离线
D:\>wget "http://mp3.baidu.com/u?u=http://www.yantaiblog.net/UploadFiles/2007-7/
aGhmbGtmbGsx.mp3"
--17:52:54-- http://mp3.baidu.com/u?u=http://www.yantaiblog.net/UploadFiles/200
7-7/aGhmbGtmbGsx.mp3
=> `u@u=http:%2F%2Fwww.yantaiblog.net%2FUploadFiles%2F2007-7%2FaGhmbG
tmbGsx.mp3'
Resolving mp3.baidu.com... done.
Connecting to mp3.baidu.com:80... connected.
HTTP request sent, awaiting response... 302 Object moved
Location: http://www.yantaiblog.net/UploadFiles/2007-7/76386053.mp3
--17:52:55-- http://www.yantaiblog.net/UploadFiles/2007-7/76386053.mp3
=> `76386053.mp3'
Resolving www.yantaiblog.net... done.
Connecting to www.yantaiblog.net:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4,505,113

0% 19,433 9.56K/s ETA 07:38
20 发表于 2008-03-18 19:12 ·  中国 浙江 温州 电信
中级用户
★★
积分 458
发帖 196
注册 2006-10-05 12:04
19年会员
UID 64614
状态 离线
楼主能否解释一下curl的keepalive选项该在什么情况下使用,如何使用

谢谢
21 发表于 2008-03-18 21:07 ·  中国 安徽 马鞍山 电信
中级用户
★★
拟谷盗
积分 312
发帖 108
注册 2007-01-21 11:36
19年会员
UID 77238
性别 男
状态 离线
Originally posted by zerocq at 2008-3-18 19:12:
楼主能否解释一下curl的keepalive选项该在什么情况下使用,如何使用

谢谢

没用过 keepalive方式的
参考

curl --manual

http://curl.haxx.se/docs/manpage.html

--keepalive-time <seconds>

This option sets the time a connection needs to remain idle before sending keepalive probes and the time between individual keepalive probes. It is currently effective on operating systems offering the TCP_KEEPIDLE and TCP_KEEPINTVL socket options (meaning Linux, recent AIX, HP-UX and more). This option has no effect if --no-keepalive is used. (Added in 7.18.0)

If this option is used multiple times, the last occurrence sets the amount.

[ Last edited by ngd on 2008-4-19 at 05:15 PM ]
FLOSS
22 发表于 2008-03-18 21:46 ·  中国 安徽 马鞍山 电信
中级用户
★★
拟谷盗
积分 312
发帖 108
注册 2007-01-21 11:36
19年会员
UID 77238
性别 男
状态 离线
Originally posted by knoppix7 at 2008-3-18 19:02:
D:\>wget "http://mp3.baidu.com/u?u=http://www.yantaiblog.net/UploadFiles/2007-7/
aGhmbGtmbGsx.mp3"
--17:52:54-- http://mp3.baidu.com/u?u=http://www.yantaiblog.net/UploadFiles/2 ... 奇怪!wget 1.10.2 D:\>wget "http://mp3.baidu.com/u?u=http://www.yantaiblog.net/UploadFiles/2007-7/ aGhmbGtmbGsx.mp3" --20:32:27-- http://mp3.baidu.com/u?u=http://www.yantaiblog.net/UploadFiles/200 7-7/aGhmbGtmbGsx.mp3 => `u@u=http%3A%2F%2Fwww.yantaiblog.net%2FUploadFiles%2F2007-7%2FaGhm bGtmbGsx.mp3' Resolving mp3.baidu.com... 220.181.38.70 Connecting to mp3.baidu.com|220.181.38.70|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://www.baidu.com/search/error.html --20:32:28-- http://www.baidu.com/search/error.html => `error.html' Resolving www.baidu.com... 220.181.6.6, 220.181.37.55 Connecting to www.baidu.com|220.181.6.6|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2,699 (2.6K) 100% 2,699 --.--K/s 20:32:38 (52.95 MB/s) - `error.html' saved
FLOSS
23 发表于 2008-03-19 19:41 ·  中国 北京 海淀区 联通
银牌会员
★★★
积分 1,287
发帖 634
注册 2007-05-02 15:06
19年会员
UID 87277
性别 男
来自 cmd.exe
状态 离线
D:\>wget --help
GNU Wget 1.8.2, a non-interactive network retriever.
24 发表于 2008-08-08 11:38 ·  中国 广东 深圳 电信
初级用户
★★
积分 153
发帖 103
注册 2008-03-27 19:38
18年会员
UID 114210
性别 男
状态 离线
curl -d "UserName=***&Password=******" http://www.netyi.net/jsLoginStatus.aspx
怎么登陆不了
论坛跳转: