[問題]我寫的爬蟲只會爬到第一個符合條件的

看板Python作者 (小樹芽)時間9年前 (2014/12/20 17:19), 9年前編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/2 (看更多)
大家好 我的問題主要是在爬資料的時候 設定好要抓的tag後 只會抓第一筆 pagelink=url.strip() request_get=requests.get(pagelink) soup_post=BeautifulSoup(request_get.text.encode('utf-8')) data = h.unescape(soup_post.find('td',{'itemprop':'actor'}).text) +',' + h.unescape(soup_post.find('td',{'class':'character'}).text) 要抓的頁面中符合這個tag的有非常多筆 但只會抓到最上面的第一筆 就跳出 接下來要怎麼寫呢 謝謝大家 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.119.164.134 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1419067173.A.705.html ※ 編輯: elmo56 (140.119.164.134), 12/20/2014 17:19:51

12/20 17:44, , 1F
findall
12/20 17:44, 1F
這個屬性不能findAll 後面.text 寫的另一種版本是全抓到 但會變成 [u' aplle ,u'banana...] ※ 編輯: elmo56 (140.119.164.134), 12/20/2014 18:27:15
文章代碼(AID): #1KbJybS5 (Python)
文章代碼(AID): #1KbJybS5 (Python)