使用带有错误URL的Wget

时间:2014-03-28 09:41:50

标签: bash cygwin wget

我有以下链接,即通过网络浏览器下载CSV文件。

http://pro.allocine.fr/film/export_classement.html?typeaffichage=2&lsttype=1001&lsttypeperiode=3002&typedonnees=visites&cfilm=&datefiltre=

但是,当使用Wget with Cygwin时,使用下面的命令,Wget将检索一个文件,该文件不是CSV文件,而是一个没有扩展名的文件。该文件为空,即根本没有数据。

wget 'http://pro.allocine.fr/film/export_classement.html?typeaffichage=2&lsttype=1001&lsttypeperiode=3002&typedonnees=visites&cfilm=&datefiltre='

因此,我不想被卡住,我也尝试了以下内容。我将URL放在一个文本文件中,并使用带有文件选项的Wget:

在fic.txt里面

'http://pro.allocine.fr/film/export_classement.html?typeaffichage=2&lsttype=1001&lsttypeperiode=3002&typedonnees=visites&cfilm=&datefiltre='

我用以下方式使用Wget:

wget -i fic.txt

我收到了以下错误:

 Scheme missing
 No URLs found in toto.txt

1 个答案:

答案 0 :(得分:2)

我想我可以建议一些其他选项,这些选项可以使您的基础问题更加清晰,因为它应该是html,但没有内容(content-length = 0)。

更具体地说,这个

wget -S -O export_classement.html 'http://pro.allocine.fr/film/export_classement.html?typeaffichage=2&lsttype=1001&lsttypeperiode=3002&typedonnees=visites&cfilm=&datefiltre='

产生这个

Resolving pro.allocine.fr... 62.39.143.50
Connecting to pro.allocine.fr|62.39.143.50|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Server: nginx
  Date: Fri, 28 Mar 2014 09:54:44 GMT
  Content-Type: text/html; Charset=iso-8859-1
  Connection: close
  X-ServerName: WEBNX2
  akamainocache: no-store
  Content-Length: 0
  Cache-control: private
  X-KompressorName: kompressor7
Length: 0 [text/html]

2014-03-28 05:54:52 (0.00 B/s) - ‘export_classement.html’ saved [0/0]

此外,服务器根据浏览器识别自身的方式定制输出。使用wget确实可以选择在头文件中包含任意用户代理。这是一个例子,当你让wget将自己标识为Chrome时会发生什么。 Here's a list of other possibiities

wget -S --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36" 'http://pro.allocine.fr/film/export_classement.html?typeaffichage=2&lsttype=1001‌​&lsttypeperiode=3002&typedonnees=visites&cfilm=&datefiltre='

现在输出更改为export.csv,类型为" application / octet-stream"而不是" text / html"

HTTP request sent, awaiting response... 
 HTTP/1.1 200 OK
 Server: nginx
 Date: Fri, 28 Mar 2014 10:34:09 GMT
 Content-Type: application/octet-stream; Charset=iso-8859-1
 Transfer-Encoding: chunked
 Connection: close
 X-ServerName: WEBNX2
 Edge-Control: no-store
 Last-Modified: Fri, 28 Mar 2014 10:34:17 GMT
 Content-Disposition: attachment; filename=export.csv
相关问题