我想用class_="_e4d"
中的class_="href"
。基本上是想用beauthoulsoup在一个类中创建一个类。在
from bs4 import BeautifulSoup
import selenium.webdriver as webdriver
url = ("https://www.google.com/search?...")
def get_related_search(url):
driver = webdriver.Chrome("C:\\Users\\John\\bin\\chromedriver.exe")
driver.get(url)
soup = BeautifulSoup(driver.page_source)
relate_result = soup.find_all("p", class_="_e4b")
return relate_result[0]
relate_url = get_related_search(url)
print(relate_url)
结果:标记类型=标记类型) p^{cl1}$
现在我要刮取href结果。我不知道下一步会是什么。谢谢你的帮助。在
注意:我用{}替换了<;>;,因为它没有显示为html脚本
实际上,您可以使用一个CSS selector一次性找到这个内部
a
元素:p._e4b a[href]
将在具有_e4b
类的p
元素内找到所有具有href
属性的{相关问题 更多 >
编程相关推荐