【发布时间】:2022-01-17 15:13:54
【问题描述】:
import pandas as pd
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.edge.service import Service
import re
driver = webdriver.Edge(service= Service("C:/Users/Peterven/Documents/msedgedriver.exe"))
#driver = webdriver.Edge(executable_path="C:/Users/Peterven/Documents/msedgedriver.exe")
driver.get("https://nigeria.startuphrtoolkit.com/top-startups-in-nigeria")
results = []
content = driver.page_source
soup = BeautifulSoup(content)
#print((soup.find("p", class_=False, id=False).find_next_sibling(text=True)))
driver.quit()
for element in soup.find_all(attrs= "wpb_wrapper"):
name = element.findAll("strong")
if name not in results:
results.append(name)
#print(soup.find('strong':contains("Contact"))
即使我使用 findAll,抓取强标签也会返回父类中的第一个标签
【问题讨论】:
-
获取html然后使用正则表达式抓取数据。
-
请问您要获取什么数据?
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
标签: python selenium beautifulsoup