
如果我在 BBC RSS 上執行 wget 效果很好:
wget http://feeds.bbci.co.uk/news/world/rss.xml
但如果我多次這樣做,我會收到 403 禁止錯誤:
wget http://www.thetimes.co.uk/tto/news/rss
儘管這應該是正確的 rss: http://www.thetimes.co.uk/tto/newsrss/?service=rss
請問我缺什麼?
答案1
在大多數情況下,為 wget 提供用戶代理將解決諸如 403 禁止之類的錯誤:
wget -U "Mozilla" http://www.thetimes.co.uk/tto/news/rss
這對我有用。
答案2
該請求可能會失敗,因為《紐約時報》正在根據提供的用戶代理進行過濾。
若要變更您的使用者代理程式以在 OSX 上模擬 Firefox,請嘗試以下操作:
wget --header="Accept: text/html" --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" http://www.thetimes.co.uk/tto/news/rss