[问题] AttributeError问题请教

楼主: carlosf1112 (熊猫眼)   2020-07-07 18:04:08
首次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,不知为何无法执行,发出求救讯号~~~呜呜
作者: bjchiou (bjchiou)   2020-07-07 18:37:00
urllib.request底下的是Request
作者: alvinlin (林矜业)   2020-07-07 21:09:00
楼主: carlosf1112 (熊猫眼)   2020-07-07 22:24:00
已经解决,感谢各位高手~~
作者: alvinlin (林矜业)   2020-07-07 23:12:00
^^

Links booklink

Contact Us: admin [ a t ] ucptt.com