|
ngd
中级用户
   拟谷盗
积分 312
发帖 108
注册 2007-1-21
状态 离线
|
『第
16 楼』:
curl和sed的问题
curl "http://220.181.38.82/m?ct=134217728&tn=baidusg,不得不爱 &word=mp3,http://www.yantaiblog.net/UploadFiles/2007-7/aGhmbGtmbGsx.mp3,,[%B2%BB%B5%C3%B2%BB%B0%AE]&si=%B2%BB%B5%C3%B2%BB%B0%AE;;%C5%CB%E7%E2%B0%D8;;51913;;51913&lm=16777216" curl: (3) [globbing] 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 |
|
2008-3-17 00:48 |
|
|
junchen2
高级用户
   
积分 537
发帖 219
注册 2007-8-4 来自 杭州--半山
状态 离线
|
『第
17 楼』:
总感觉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 ]
|
|
2008-3-17 13:53 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第
18 楼』:
像from提交的网页用 wget 和 curl 都可以解决,两个都试下就好了
|
|
2008-3-18 16:24 |
|
|
knoppix7
银牌会员
    
积分 1287
发帖 634
注册 2007-5-2 来自 cmd.exe
状态 离线
|
|
2008-3-18 19:02 |
|
|
zerocq
中级用户
  
积分 458
发帖 196
注册 2006-10-5
状态 离线
|
『第
20 楼』:
楼主能否解释一下curl的keepalive选项该在什么情况下使用,如何使用
谢谢
|
|
2008-3-18 19:12 |
|
|
ngd
中级用户
   拟谷盗
积分 312
发帖 108
注册 2007-1-21
状态 离线
|
『第
21 楼』:
Quote: | 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 |
|
2008-3-18 21:07 |
|
|
ngd
中级用户
   拟谷盗
积分 312
发帖 108
注册 2007-1-21
状态 离线
|
『第
22 楼』:
Quote: | 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-- [url]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:// ... 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 [following]
--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) [text/html]
100%[====================================>] 2,699 --.--K/s
20:32:38 (52.95 MB/s) - `error.html' saved [2699/2699]
|

FLOSS |
|
2008-3-18 21:46 |
|
|
knoppix7
银牌会员
    
积分 1287
发帖 634
注册 2007-5-2 来自 cmd.exe
状态 离线
|
『第
23 楼』:
D:\>wget --help
GNU Wget 1.8.2, a non-interactive network retriever.
|
|
2008-3-19 19:41 |
|
|
kioskboy
初级用户
 
积分 153
发帖 103
注册 2008-3-27
状态 离线
|
|
2008-8-8 11:38 |
|