作者carlosf1112 (熊貓眼)
看板Python
標題[問題] AttributeError問題請教
時間Tue Jul 7 18:04:08 2020
首次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,不知為何無法執行,發出求救訊號~~~嗚嗚
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.47.168.212 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1594116250.A.9DD.html
→ bjchiou: urllib.request底下的是Request 07/07 18:37
→ alvinlin: 應該是這樣 07/07 21:09
→ carlosf1112: 已經解決,感謝各位高手~~ 07/07 22:24
→ alvinlin: ^^ 07/07 23:12