【发布时间】:2022-08-07 22:50:09
【问题描述】:
我正在尝试使用 selenium 进行抓取(用于在 python 3.7 中工作的脚本)。
上周我不得不重置我的电脑,并安装了最新版本的 python 和脚本中使用的所有包。
我观察到的是,没有一个动态值被渲染并与标题标签一起显示。请参阅下面的一些输出:
<tr>
<td class=\"textsr\">Close</td>
<td class=\"textvalue\">{{ScripHeaderData.Header.Close}}</td>
</tr>
<tr>
<td class=\"textsr\">WAP</td>
<td class=\"textvalue\">{{StkTrd.WAP}}</td>
</tr>
<tr>
<td class=\"textsr\">Big Value</td>
<td class=\"textvalue\">{{checknullheader(CompData.BigVal)?\'-\':(CompData.BigVal)}}</td>
</tr>
我一直在将脚本用于我的研究目的,并且需要它恢复原状,因此感谢任何指导。
这是sn-p供参考:
target_url = q.get(timeout=1)
time.sleep(1)
driver = webdriver.Chrome(\'./chromedriver\',options=opts)
driver.get(target_url)
# this is just to ensure that the page is loaded
time.sleep(5)
html_content = driver.page_source
soup = BeautifulSoup(html_content, features=\"html.parser\")
table_rows = soup.find_all(\'tr\')
for row in table_rows:
table_cols = row.find_all(\'td\')
for col in table_cols:
label_value = col.text
标签: python beautifulsoup selenium-chromedriver