简体   繁体   English

使用 Beautiful Soup/Selenium 对动态表进行增补时,我无法获得完整的 html 代码

[英]I can't get full html code when souping a dynamic table using Beautiful Soup/Selenium

I am having troubles souping a dynamic table with Beautiful soup/Selenium我在用 Beautiful soup/Selenium 给动态表加汤时遇到了麻烦

When I run the code, I can´t get the entire html code in my notebook.当我运行代码时,我无法在笔记本中获取整个 html 代码。

The tags I am interested with are under the tag 'frameset' which I should somehow "open".我感兴趣的标签位于标签“框架集”下,我应该以某种方式“打开”。 How could I do this?我怎么能这样做?

driver = webdriver.Chrome('/Users/Administrador/Documents/chromedriver')
main_url = 'https://www.justiciacordoba.gob.ar/Estatico/JEL/Escrutinios/ReportesEleccion20190512/default.html'
driver.get(main_url)
soup = BeautifulSoup(driver.page_source, 'lxml')
soup

output : <html><head></head><frameset border="0" cols="*" frameborder="NO" framespacing="0" id="fset" rows="190,*">
<frame name="topFrame" scrolling="NO" src="Index.html"/>
<frame align="center" name="mainFrame" src="about:blank"/>
</frameset><noframes></noframes>
</html>

Change the driver's frame and store the value:更改驱动程序的框架并存储该值:

driver.switch_to.frame(driver.find_element_by_name("topFrame"))
frame_source = driver.page_source

The frame_source variable should store the iframe's source code. frame_source 变量应该存储 iframe 的源代码。 I checked the website, and the iframe's name is 'topFrame'.我检查了网站,iframe 的名称是“topFrame”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM