【发布时间】:2019-01-12 06:12:53
【问题描述】:
我不明白为什么我会收到其中一些网站的 403 错误。
如果我手动访问 URL,页面加载正常。除了 403 响应之外没有任何错误信息,所以我不知道如何诊断问题。
from bs4 import BeautifulSoup
import requests
test_sites = [
'http://fashiontoast.com/',
'http://becauseimaddicted.net/',
'http://www.lefashion.com/',
'http://www.seaofshoes.com/',
]
for site in test_sites:
print(site)
#get page soure
response = requests.get(site)
print(response)
#print(response.text)
上面代码运行的结果是……
http://fashiontoast.com/
Response [403]
http://becauseimaddicted.net/
Response [403]
http://www.lefashion.com/
Response [200]
http://www.seaofshoes.com/
Response [200]
谁能帮我理解问题的原因和解决方法?
【问题讨论】:
标签: python-3.x beautifulsoup http-status-code-403