刮擦此页面时:
https://www.hkex.com.hk/products/listed-derivatives/equity-index/hang-seng-ing-index-(hsi(/hang-seng-index-futures?sc_lang = en#en#= hsi
在Google Chrome键F12中,我看到XPATH
t//*[@id="equity_future"]
有一个斜纹和一个tbody。tbody可用。
但是,在python3调试器内,带有
wdriver = webdriver.PhantomJS()
wdriver.get(url)
soup = BeautifulSoup(wdriver.page_source,"lxml")
我确实看到了 thead 孩子,但是 tbody 出现为空
<tbody>
</tbody>
有什么想法?
如果提取 page_source
,则仅使用硒,您可以找到所有 <tbody>
标签标签,如下:
-
代码块:
driver = webdriver.PhantomJS(executable_path=r'C:WebDriversphantomjs.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>