简体   繁体   中英

Beautiful Soup find href inside a child element

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.

尝试使用:-

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

try this:

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

this should work without knowing the infos before the div

 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

使用以下内容:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM