如何获取<a> using BeautifulSoup in python?

时间:2017-07-24 18:20:28

标签: python beautifulsoup

result=requests.get("https://www.google.co.in/searchq=ntest&oq=ntest&aqs=chrome..69i57j69i61j35i39l2j0l2.4898j0j7&sourceid=chrome&ie=UTF-8")
page=result.text
doc=soup(page,"html5lib")

a=doc.find_all('h3',{'class':'r'})

for i in a:
    b=i.a
    print(b.get('data-href'))

i dont know why it is unable to access the data-href attribute of anchor tag.

0 个答案:

没有答案