首次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,不知為何無法執行,發出求救訊號~~~嗚嗚