【发布时间】:2020-04-18 06:13:59
【问题描述】:
我正在尝试从网络上抓取这个 ->
HTML 有一个带有类的 div 标签。在这个 div 标签中有另一个 div 标签,还有另一个没有类的 p 标签。我的目标是专门获取没有类的唯一 p 标签并从中获取文本数据。
到目前为止,这是我的代码 ->
我没有包含一些导入和我的代码的其他部分。
html = driver.page_source
time.sleep(.1)
soup = bs.BeautifulSoup(html, 'lxml')
time.sleep(.1)
Class_Details = soup.find_all("div", {"class":"row-fluid data_row primary-row class-info class-not-checked"})
for class_detail in Class_Details:
Class_status = class_detail.find_all("div", {"class":"statusColumn"})
Status = Class_status[0].text
class_date = class_detail.find_all("p",{"class":"hide-above-small beforeCollapseShow"})
class_time = class_date[0].text
The 4 lines above can be ignored they work and accomplish their tasks, the lines below however do not and is what I am asking.
cla = class_detail.find_all("p",{"class":"timeColumn"})
print(cla)
The Output of print(cla) is
[]
[]
[]
[]
[]
[]
[]
好消息是有 7 个空列表与网站一致,所以它肯定是在计算/感知我正在抓取的部分,但是我需要输出为文本。
我希望我的问题很清楚,感谢您抽出宝贵时间。
【问题讨论】:
-
如果您根本不需要硒,该网址会有所帮助
标签: python html selenium web-scraping beautifulsoup