我正在尝试使用 wget 检索显示搜索字符串结果的网页。但是,检索到的页面仅显示空字符串的结果。从外观上看,搜索词被放置在某种数组中。如何使用 wget 检索整个 URL?
name@ubuntu:~$ wget -U 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4' http://www.somesite.com/search?tm_link=tm_header_search&user_input=search+of+terms&q=search+of+terms
[1] 2938 [2] 2939 name@ubuntu:~$ --2013-11-07 21:22:03-- http://www.somesite.com/search?tm_link=tm_header_search
Resolving www.somesite.com (www.somesite.com)... 23.42.84.199 Connecting to www.somesite.com (www.somesite.com)|23.42.84.199|:80... connected. HTTP request sent, awaiting response... 200 OK Syntax error in Set-Cookie: GEORAN=1; path=/; domain=.somesite.com; expires= at position 52. Length: unspecified [text/html] Saving to: `search?tm_link=tm_header_search'
[ <=> ] 146,249 --.-K/s in 0.1s
2013-11-07 21:22:04 (1.14 MB/s) - `search?tm_link=tm_header_search' saved [146249]
答案1
您的 shell 调用语法错误。您所做的是调用wget -U 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4' http://www.somesite.com/search?tm_link=tm_header_search
(注意'
在用户代理之后关闭),并且&
是命令 shell 设置wget
为后台。此点之外的所有内容都是单独的命令。
您需要将命令修正为类似wget -U 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4' 'http://www.somesite.com/search?tm_link=tm_header_search&user_input=search+of+terms&q=search+of+terms'