首次python版发文,内容若有违反版规,请版主大人告知我,我再删除
刚学爬虫,发生下面问题,请版上各位高手指导,感恩~~
程式内容:
import urllib.request as req
url="https://www.ptt.cc/bbs/movie/index.html"
request=req.request(url,headers={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Edge/18.18362"
})
with req.request(request) as response:
data=response.read().decode("utf-8")
print(data)
执行结果:
Traceback (most recent call last):
request=req.request(url,headers={
AttributeError: module 'urllib.request' has no attribute 'request'
我的版本是3.8,不知为何无法执行,发出求救讯号~~~呜呜