Beautiful Soup find href inside a child element

て烟熏妆下的殇ゞ 提交于 2019-12-13 03:53:10

问题


I already tried different solutions, but I can't get the href inside the <a> element. I can reach the div class with soup.select("div.quicklinks") but then I do not know how to take the href with title=Details.

Thnaks for the help.


回答1:


try using:-

divElement.find("a", { "title" : "Details" })



回答2:


try this:

link = soup.find('div').find('a').get('href')

this should work without knowing the infos before the div




回答3:


urls=[]
result=driver.find_elements_by_class_name("quicklinks")
for res in result:
    url=res.find_element_by_tag_name("a").get_attribute("href")
    urls.append(url)
for u in urls:
    driver.get(u)

i have no idea about beautiful soup but u can make url scrapping from above code




回答4:


Use the following:-

soup.select("div.quicklinks").find("a", title="Details")


来源:https://stackoverflow.com/questions/50328617/beautiful-soup-find-href-inside-a-child-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!