簡體   English   中英

將Wget與錯誤的URL結合使用

[英]Using Wget with buggy URL

我有以下鏈接,當通過網絡瀏覽器放置時,該鏈接正在下載CSV文件。

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

但是,將Wget與Cygwin一起使用時,通過以下命令,Wget會檢索一個文件,該文件不是CSV文件,而是沒有擴展名的文件。 該文件為空,即完全沒有數據。

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

因此,由於我不想被卡住,我也嘗試了以下方法。 我將URL放在一個文本文件中,並將Wget與file選項一起使用:

在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

我想我可以建議其他一些選擇,這些選擇可以使您的根本問題更加清楚,那就是它應該是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時會發生什么。 這是其他可能性的清單

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM