代码拉取完成,页面将自动刷新
我用 python 3 的 urlopen 来获取 gitee page 中的远程数据时出现"urllib.error.HTTPError: HTTP Error 403: Forbidden";同样情况下,获取 github page 远程数据时显示是正常的。请问这是 gitee 做了什么操作吗?怎么样才能实现类似 github page 的效果?
Python 3.6.10 (default, Jun 3 2020, 09:40:13)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.request import urlopen
>>> path_or_url="https://usegalaxy-cn.gitee.io/res/test-data/heatmap/heatmap-test.tab"
>>> urlopen(path_or_url)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/software/python-3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/data/software/python-3.6/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/data/software/python-3.6/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/data/software/python-3.6/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/data/software/python-3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/data/software/python-3.6/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
>>> urlopen("https://shenweiyan.github.io/startbootstrap-creative/assets/img/bg-masthead.jpg")
<http.client.HTTPResponse object at 0x7f9a548e2e48>
>>>
希望 gitee page 能和 github page 一样,使用相同的方法获取静态资源时,不会出现额外的异常。