作者elmo56 (小树芽)
看板Python
标题[问题] 我写的爬虫只会爬到第一个符合条件的
时间Sat Dec 20 17:19:31 2014
大家好
我的问题主要是在爬资料的时候
设定好要抓的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://webptt.com/cn.aspx?n=bbs/Python/M.1419067173.A.705.html
※ 编辑: elmo56 (140.119.164.134), 12/20/2014 17:19:51
1F:推 Seudo: findall 12/20 17:44
这个属性不能findAll 後面.text
写的另一种版本是全抓到 但会变成 [u' aplle ,u'banana...]
※ 编辑: elmo56 (140.119.164.134), 12/20/2014 18:27:15