蟒蛇beautifulsoup如何获得“HREF”之后的行 [英] Python beautifulsoup how to get the line after 'href'

查看:209
本文介绍了蟒蛇beautifulsoup如何获得“HREF”之后的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这一块的html:

I have this piece of html:

<a href="http://francetv.fr/videos/alcaline_l_instant_,12163184.html"  class="ss-titre">
                                "Paris Combo"                   </a>    
<a href="http://francetv.fr/videos/jt20h_,12185324.html" class="ss-titre"> 
                            Journal         </a>

我能获得 http://francetv.fr/videos/jt20h_,12185324.html (例如,不是真正的ADRESS),但现在,
我想,用beautifulsoup,得到巴黎二合一和日报。
我想这样的:

I can get http://francetv.fr/videos/jt20h_,12185324.html (example, not the real adress) but now, I would like, using beautifulsoup, to get "Paris Combo", and "Journal". I tried this:

for line in soup.findAll('/a'):
              title = line.get('</a>')

我该怎么办?
谢谢

How can I do? Thanks

推荐答案

您需要调用 find_all(A)代替。

>>> for line in soup.find_all("a"):
...     print(line.text.strip())
"Paris Combo"
Journal

这篇关于蟒蛇beautifulsoup如何获得“HREF”之后的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆