问题
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