python-3.x - selenium phantomjs 在那里但 tbody 丢失
问题描述
抓取此页面时:
在谷歌浏览器键 F12 中,我看到了 xpath
t//*[@id="equity_future"]
有一个thead和一个tbody。tbody 可用。
但是,在 python3 调试器中,使用
wdriver = webdriver.PhantomJS()
wdriver.get(url)
soup = BeautifulSoup(wdriver.page_source,"lxml")
我确实看到了孩子们,但身体似乎是空的
<tbody>
</tbody>
有任何想法吗?
解决方案
如果您提取仅使用Seleniumpage_source
,您可以找到所有<tbody>
标签,如下所示:
代码块:
driver = webdriver.PhantomJS(executable_path=r'C:\WebDrivers\phantomjs.exe') driver.get("https://www.hkex.com.hk/Products/Listed-Derivatives/Equity-Index/Hang-Seng-Index-(HSI)/Hang-Seng-Index-Futures?sc_lang=en#&product=HSI") print(driver.page_source)
控制台输出片段 1:
<tbody> <tr> <td class="ls">Last Traded</td> <td class="vo">Volume</td> <td class="oi">Prev.Day Open Interest</td> </tr> </tbody>
控制台输出片段 2:
<tbody> <tr> <td class="se">Prev.Day Settlement Price</td> <td class="vo">Volume</td> <td class="oi">Prev.Day Open Interest</td> </tr> </tbody>
推荐阅读
- javascript - Vue 在 v-if 参数更改时不更新相同类型的组件
- graphviz - 我如何保证一个graphviz集群总是在最后?
- java - 高负载系统的Java Stream API功能接口优化
- r - 在 r 中创建具有分组均值的列
- javascript - 无法获得续集 findbyPk 以将单个值返回到我的 React 应用程序
- dhall - dhall-to-yaml 函数文本输出以双引号输出
- java - 我的 heroku java 应用程序(电报机器人)不会在启动时编译
- jquery - JQuery循环使用for循环通过多维json数组
- python - 检查当前单词是否接近字符串中的单词的有效方法是什么?
- javascript - 任务:react-native-webview:compileDebugJavaWithJavac FAILED