Re: [問題] 無法成功顯示表特版圖片連結

看板Python作者 (貓貓)時間5年前 (2019/10/17 13:51), 編輯推噓2(209)
留言11則, 5人參與, 5年前最新討論串3/3 (看更多)
※ 引述《wsybu (%小步步%)》之銘言: : ※ 引述《hosayhosay (貓貓)》之銘言: : : rs=requests.session() : : rs.post('https://www.ptt.cc/ask/over18', verify=False,data=payload) : : url='https://www.ptt.cc/bbs/Beauty/index.html' : : res=rs.get(url,verify=False) : : print(res.text) : : soup=BeautifulSoup(res.text,'html.parser') : : articles= soup.select('div.title a') : : for art in articles: : : print(art) : : res = requests.get('https://www.ptt.cc/bbs'+art['href']) : 你前面18歲驗證已經放在rs裡面了, 所以你這邊要改成rs.get : 然後文章網址多了一個bbs路徑 : 所以改成 res = rs.get('https://www.ptt.cc'+art['href'], verify=False) : 試看看 ~~~.謝謝小步步大大您的熱心,我試過以後它顯示錯誤訊息,不知道為什會這樣 以下是錯誤訊息: Traceback (most recent call last): File "pttimg6.py", line 1, in <module> import requests File "D:\python\requests.py", line 11, in <module> rs=requests.session() AttributeError: module 'requests' has no attribute 'session' -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 112.105.240.112 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1571291501.A.984.html

10/17 13:53, 5年前 , 1F
大寫?
10/17 13:53, 1F

10/17 16:04, 5年前 , 2F
把你自己範例的requests.py改成別的名字就好了
10/17 16:04, 2F

10/17 21:26, 5年前 , 3F
requests.session已deprecated、必須改寫,請參考help
10/17 21:26, 3F

10/17 21:29, 5年前 , 4F
可是為何一開始能得到清單,中間曾更新套件嗎?
10/17 21:29, 4F

10/17 22:15, 5年前 , 5F
謝謝w大大~~ 終於試成功了
10/17 22:15, 5F

10/17 22:17, 5年前 , 6F
bj大大 其實我不太懂它中間發生什麼事
10/17 22:17, 6F

10/18 00:27, 5年前 , 7F
因為如果你的檔名和模組的一樣,它會先抓現在目錄下已存
10/18 00:27, 7F

10/18 00:27, 5年前 , 8F
在的而不是模組上的
10/18 00:27, 8F

10/18 08:32, 5年前 , 9F
嗯嗯謝謝al大大 受教了原來是這樣
10/18 08:32, 9F

10/18 11:03, 5年前 , 10F
托hosayhosay的福,我也學到了!感謝!
10/18 11:03, 10F

10/20 07:41, 5年前 , 11F
bj大 不會哦謝謝您
10/20 07:41, 11F
文章代碼(AID): #1Tg05jc4 (Python)
文章代碼(AID): #1Tg05jc4 (Python)