我的Python / WebKit代码正在跳过标签

时间:2018-03-23 14:04:18

标签: python-3.x webkit pyqt5

我对这个“幽灵”数据有疑问。我假设它是动态java,但我不是一个高手,我似乎无法弄清楚为什么<tbody>标签被遗漏了。我尝试了几种不同的方式,无论我运行该标签,输出的一部分总是被跳过。以下是网站Website Inspect Window的检查窗口图片 这是代码:

    import sys  
    from PyQt5.QtGui import *  
    from PyQt5.QtCore import *  
    from PyQt5.QtWebKit import *  
    from lxml import html 
    from PyQt5.QtWebKitWidgets import QWebPage
    from PyQt5.QtWidgets import QApplication

    class Render(QWebPage):  
      def __init__(self, url):  
        self.app = QApplication(sys.argv)  
        QWebPage.__init__(self)  
        self.loadFinished.connect(self._loadFinished)  
        self.mainFrame().load(QUrl(url))  
        self.app.exec_()  

      def _loadFinished(self, result):  
        self.frame = self.mainFrame()  
        self.app.quit()

    url = 
('https://cib.societegenerale.com/fileadmin/indices_feeds/ti_screen/index.html')  
    #This does the magic.Loads everything
    r = Render(url)  
    #result is a QString.
    result = r.frame.toHtml()
    print(result)

这是输出:

    <div id="watchlist" align="right">
            <table id="watchlistTable" class="hover" cellspacing="0" width="100%">
                    <thead>
                            <tr>
                                    <td colspan="8" class="heading" align="left">Market Signal Watch List</td>
                            </tr>
                            <tr>
                                    <th></th>
                                    <th>Market</th>
                                    <th>Current Position</th>
                                    <th>Yesterday's Close</th>
                                    <th>20 Day Moving Average</th>
                                    <th>120 Day Moving Average</th>
                                    <th>Reversal Price</th>
                                    <th>Reversal Price Move</th>
                            </tr>
                    </thead>
            </table>
            <div class="source">source: SG Prime Services &amp; Bloomberg</div>
    </div>

正如您所看到的,<tbody>标签无处可寻。有没有人有任何想法?

0 个答案:

没有答案