我正在尝试加载一个 url,但我收到了这个错误:
DownloadError: ApplicationError: 2 重复重定向太多
这是我正在使用的代码:
headers = { 'User-Agent' : 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1' }
url = "http://www.cafebonappetit.com/menu/your-cafe/collins-cmc/cafes/details/50/collins-bistro"
cmcHTM = urlfetch.fetch(url=url)
cmcHTML = str(cmcHTM.content)
我检查了这个网站的重定向:http: //www.internetofficer.com/seo-tool/redirect-check/ ,我发现这个网站被重定向到它自己!所以 url fetch 似乎在试图加载这个页面。同时,这个页面在我的浏览器中加载得很好。
所以我尝试使用这段代码:
cmcHTM = urlfetch.fetch(url=url,
follow_redirects=False,
deadline=100
)
但这只是什么都不返回。有没有办法得到这个html?!