在大多数情况下,如何从<a> python parser

时间:2016-07-18 10:28:43

标签: python python-3.x html-parsing

<a class="button button-mini" href="www.example-link.com.c"><b>TEXT</b></a>

I'm creating Python parser, and i need to get link from this tag. I tried this, but result was "None":

link = table.find_all('td')[1].a.href
link = table.find_all('td')[1].a.link

Using Beautiful Soup 4 & Python 3.5

1 个答案:

答案 0 :(得分:1)

我认为这是一个非常简单的问题,你只是缺少参数。 它应该写成:

link = table.find_all('td')[1].a.get('href')

修改记事

在回答用户已回复您的评论后,您已经注意到了......不想窃取任何信用。