[問題] wget 下載網頁 src="//..."

看板Linux作者 (VElysian)時間7年前 (2018/08/31 22:33), 7年前編輯推噓1(1014)
留言15則, 5人參與, 7年前最新討論串1/1
如題 用 wget 下載的網頁含有圖片 網址: https://www.mobile01.com/newsdetail/26682/eric-bike 圖片: src="//attach.mobile01.com/attach/201808/mobile01-abfe7e57cf816f7fb5fdcf08d1e98b34.jpg" 假設原始碼為 src="//image.jpg" wget 遇到這樣的連結都無動於衷, 導致下載的網頁不完整。 請問有沒有解決辦法,感激不盡! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.42.124.125 ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1535725982.A.547.html

08/31 23:59, 7年前 , 1F
下載的命令完整參數是 ?
08/31 23:59, 1F

09/01 00:17, 7年前 , 2F
wget -HpkKE url
09/01 00:17, 2F

09/01 00:19, 7年前 , 3F
找到 manual 中 --convert-file-only 有寫
09/01 00:19, 3F

09/01 00:20, 7年前 , 4F
The rest of the URL has been left untouched,
09/01 00:20, 4F

09/01 00:20, 7年前 , 5F
including the net path ("//") which would otherwise
09/01 00:20, 5F

09/01 00:20, 7年前 , 6F
be processed by Wget and converted to the effective
09/01 00:20, 6F

09/01 00:20, 7年前 , 7F
scheme (ie. "http://").
09/01 00:20, 7F

09/01 00:21, 7年前 , 8F
可是下載的檔案裡還是 src="//... 啊 ><"
09/01 00:21, 8F

09/01 00:21, 7年前 , 9F
試試看 -m 或 -r
09/01 00:21, 9F

09/01 00:45, 7年前 , 10F
結果還是一樣:wget -HpkKE -r -l 1 url
09/01 00:45, 10F
加入下載連結 ※ 編輯: VElysian (114.42.124.125), 09/01/2018 01:04:45

09/01 01:52, 7年前 , 11F
你要從瀏覽器的角度去思考,看到 // 瀏覽器會自動把 // 轉
09/01 01:52, 11F

09/01 01:52, 7年前 , 12F
成跟當前頁面一樣協定
09/01 01:52, 12F

09/01 01:53, 7年前 , 13F
比方說你網頁在 https://,當下頁面的 src="//開頭網址"
09/01 01:53, 13F

09/01 01:53, 7年前 , 14F
就會被當成 src="https://兩斜線後面都一樣" 處理
09/01 01:53, 14F

09/01 13:15, 7年前 , 15F
用 --convert-links
09/01 13:15, 15F
文章代碼(AID): #1RYL6UL7 (Linux)
文章代碼(AID): #1RYL6UL7 (Linux)