【发布时间】:2018-07-07 01:22:50
【问题描述】:
我正在尝试抓取一个票务网站,以便在有新票可用时收到通知(注意:我不是试图通过自动化非法购买这张票)。
from urllib.request import Request, urlopen
from bs4 import BeautifulSoup
import urllib.request
req = urllib.request.Request('http://www.moshtix.com.au/v2/event/splendour-in-the-grass/103360', headers={'User-Agent': 'Mozilla/5.0'})
html = urllib.request.urlopen(req).read()
print(html)
这是以下错误:
lib/python3.7/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
我已经尝试使用相关问题的答案,错误代码相同,但都失败了。
【问题讨论】:
-
当您将 curl 与该用户代理一起使用时,您会得到相同的结果吗?
-
没试过,不知道怎么样..
标签: python security beautifulsoup http-status-code-403