Python web抓取问题-结果与soruce代码不同

Python web抓取问题-结果与soruce代码不同,python,web-scraping,Python,Web Scraping,下面的代码无法刮取类=数据行。我也尝试过使用read_html,但是这个表中有一些表,这使得read_html对我不起作用。我不知道怎么弄到这张桌子 from bs4 import BeautifulSoup import pandas as pd import requests import openpyxl import scrapy path = 'C:/Users/pacc_/OneDrive/Desktop/Eric/Investment/Trading record python.x

下面的代码无法刮取
类=数据行
。我也尝试过使用read_html,但是这个表中有一些表,这使得read_html对我不起作用。我不知道怎么弄到这张桌子

from bs4 import BeautifulSoup
import pandas as pd
import requests
import openpyxl
import scrapy
path = 'C:/Users/pacc_/OneDrive/Desktop/Eric/Investment/Trading record python.xlsx'
page_link = 'https://www.hkex.com.hk/Market-Data/Securities-Prices/Equities?sc_lang=en'
   
page_response = requests.get(page_link, timeout=2)
page_content = BeautifulSoup(page_response.content, "html.parser")
data = page_content.find(class_='table_equities')
    
print(data)
我的结果是:

<table class="table_equities">
    <tr>
        <th class="th code">
            <table>
                <thead>
                    <tr>
                        <th class="text"></th>
                        <th class="ico"><i></i></th>
                    </tr>
                </thead>
            </table>
        </th>
        <th class="th name">
            <table>
                <thead>
                    <tr>
                        <th class="text"></th>
                        <th class="ico"><i></i></th>
                    </tr>
                </thead>
            </table>
        </th>
        <th class="th price">
            <table>
                <thead>
                    <tr>
                        <th class="text"></th>
                        <th class="ico"><i></i></th>
                    </tr>
                </thead>
            </table>
        </th>
        <th class="th turnover selected uppercase">
            <table>
                <thead>
                    <tr>
                        <th class="text"></th>
                        <th class="ico"><i></i></th>
                    </tr>
                </thead>
            </table>
        </th>
        <th class="th mktcap">
            <table>
                <thead>
                    <tr>
                        <th class="text"></th>
                        <th class="ico"><i></i></th>
                    </tr>
                </thead>
            </table>
        </th>
        <th class="th pe">
            <table>
                <thead>
                    <tr>
                        <th class="text"></th>
                        <th class="ico"><i></i></th>
                    </tr>
                </thead>
            </table>
        </th>
        <th class="th div_yield">
            <table>
                <thead>
                    <tr>
                        <th class="text"></th>
                        <th class="ico"><i></i></th>
                    </tr>
                </thead>
            </table>
        </th>
        <th class="th intraday">
            <table>
                <thead>
                    <tr>
                        <th class="text"></th>
                        <th class="ico"><i></i></th>
                    </tr>
                </thead>
            </table>
        </th>
    </tr>
</table>

目标url结构:

<table class="table_equities">
    <tbody>
        <tr>
            <th class="th code">
                <table>
                    <thead>
                        <tr>
                            <th class="text">Stock Code</th>
                            <th class="ico"><i></i></th>
                        </tr>
                    </thead>
                </table>
            </th>
            <th class="th name">
                <table>
                    <thead>
                        <tr>
                            <th class="text">Name</th>
                            <th class="ico"><i></i></th>
                        </tr>
                    </thead>
                </table>
            </th>
            <th class="th price">
                <table>
                    <thead>
                        <tr>
                            <th class="text">Nominal Price</th>
                            <th class="ico"><i></i></th>
                        </tr>
                    </thead>
                </table>
            </th>
            <th class="th turnover selected uppercase">
                <table>
                    <thead>
                        <tr>
                            <th class="text">Turnover (HK$)</th>
                            <th class="ico"><i></i></th>
                        </tr>
                    </thead>
                </table>
            </th>
            <th class="th mktcap">
                <table>
                    <thead>
                        <tr>
                            <th class="text">Market Cap (HK$)</th>
                            <th class="ico"><i></i></th>
                        </tr>
                    </thead>
                </table>
            </th>
            <th class="th pe">
                <table>
                    <thead>
                        <tr>
                            <th class="text">P/E</th>
                            <th class="ico"><i></i></th>
                        </tr>
                    </thead>
                </table>
            </th>
            <th class="th div_yield">
                <table>
                    <thead>
                        <tr>
                            <th class="text">Dividend Yield (%)</th>
                            <th class="ico"><i></i></th>
                        </tr>
                    </thead>
                </table>
            </th>
            <th class="th intraday">
                <table>
                    <thead>
                        <tr>
                            <th class="text">Intraday Movement</th>
                            <th class="ico"><i></i></th>
                        </tr>
                    </thead>
                </table>
            </th>
        </tr>
        <tr class="datarow">
            <td class="code"><a>909</a></td>
            <td class="name"><a>MING YUAN CLOUD</a></td>
            <td class="price"><bdo>HK$30.700</bdo>
                <br>
                <div><span>0.000</span> (<span>0.00%</span>)</div>
            </td>
            <td class="turnover">8.35B</td>
            <td class="market">57.44B</td>
            <td class="pe">-</td>
            <td class="dividend">-</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=0909.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (909)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>700</a></td>
            <td class="name"><a>TENCENT</a></td>
            <td class="price"><bdo>HK$503.500</bdo>
                <br>
                <div class="downval"><span>-1.500</span> (<span>-0.30%</span>)</div>
            </td>
            <td class="turnover">6.69B</td>
            <td class="market">4,824.90B</td>
            <td class="pe">46.13x</td>
            <td class="dividend">0.24%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=0700.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (700)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>9988</a></td>
            <td class="name"><a>BABA-SW</a></td>
            <td class="price"><bdo>HK$258.000</bdo>
                <br>
                <div class="downval"><span>-3.000</span> (<span>-1.15%</span>)</div>
            </td>
            <td class="turnover">3.97B</td>
            <td class="market">5,584.43B</td>
            <td class="pe">-</td>
            <td class="dividend">-</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=9988.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (9988)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>3690</a></td>
            <td class="name"><a>MEITUAN-W</a></td>
            <td class="price"><bdo>HK$232.000</bdo>
                <br>
                <div class="downval"><span>-6.600</span> (<span>-2.77%</span>)</div>
            </td>
            <td class="turnover">3.75B</td>
            <td class="market">1,364.39B</td>
            <td class="pe">547.17x</td>
            <td class="dividend">-</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=3690.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (3690)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>3333</a></td>
            <td class="name"><a>EVERGRANDE</a></td>
            <td class="price"><bdo>HK$13.780</bdo>
                <br>
                <div class="downval"><span>-1.440</span> (<span>-9.46%</span>)</div>
            </td>
            <td class="turnover">2.80B</td>
            <td class="market">180.00B</td>
            <td class="pe">9.59x</td>
            <td class="dividend">5.15%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=3333.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (3333)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>1810</a></td>
            <td class="name"><a>XIAOMI-W</a></td>
            <td class="price"><bdo>HK$19.720</bdo>
                <br>
                <div class="downval"><span>-0.120</span> (<span>-0.60%</span>)</div>
            </td>
            <td class="turnover">2.69B</td>
            <td class="market">475.78B</td>
            <td class="pe">42.69x</td>
            <td class="dividend">-</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=1810.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (1810)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>2318</a></td>
            <td class="name"><a>PING AN</a></td>
            <td class="price"><bdo>HK$80.350</bdo>
                <br>
                <div class="downval"><span>-0.100</span> (<span>-0.12%</span>)</div>
            </td>
            <td class="turnover">1.49B</td>
            <td class="market">598.41B</td>
            <td class="pe">8.61x</td>
            <td class="dividend">2.89%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=2318.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (2318)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>388</a></td>
            <td class="name"><a>HKEX</a></td>
            <td class="price"><bdo>HK$355.800</bdo>
                <br>
                <div class="downval"><span>-1.800</span> (<span>-0.50%</span>)</div>
            </td>
            <td class="turnover">1.49B</td>
            <td class="market">451.09B</td>
            <td class="pe">47.50x</td>
            <td class="dividend">1.88%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=0388.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (388)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>1918</a></td>
            <td class="name"><a>SUNAC</a></td>
            <td class="price"><bdo>HK$28.950</bdo>
                <br>
                <div class="downval"><span>-1.600</span> (<span>-5.24%</span>)</div>
            </td>
            <td class="turnover">1.36B</td>
            <td class="market">134.94B</td>
            <td class="pe">4.44x</td>
            <td class="dividend">4.64%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=1918.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (1918)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>981</a></td>
            <td class="name"><a>SMIC</a></td>
            <td class="price"><bdo>HK$18.580</bdo>
                <br>
                <div class="downval"><span>-0.760</span> (<span>-3.93%</span>)</div>
            </td>
            <td class="turnover">1.35B</td>
            <td class="market">143.03B</td>
            <td class="pe">59.55x</td>
            <td class="dividend">-</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=0981.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (981)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>1299</a></td>
            <td class="name"><a>AIA</a></td>
            <td class="price"><bdo>HK$77.650</bdo>
                <br>
                <div class="upval"><span>+1.000</span> (<span>+1.30%</span>)</div>
            </td>
            <td class="turnover">1.34B</td>
            <td class="market">939.05B</td>
            <td class="pe">18.03x</td>
            <td class="dividend">1.65%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=1299.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (1299)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>2300</a></td>
            <td class="name"><a>AMVIG HOLDINGS</a></td>
            <td class="price"><bdo>HK$2.140</bdo>
                <br>
                <div class="upval"><span>+0.700</span> (<span>+48.61%</span>)</div>
            </td>
            <td class="turnover">1.31B</td>
            <td class="market">1.98B</td>
            <td class="pe">6.35x</td>
            <td class="dividend">5.33%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=2300.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (2300)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>1398</a></td>
            <td class="name"><a>ICBC</a></td>
            <td class="price"><bdo>HK$3.990</bdo>
                <br>
                <div class="downval"><span>-0.030</span> (<span>-0.75%</span>)</div>
            </td>
            <td class="turnover">1.28B</td>
            <td class="market">346.30B</td>
            <td class="pe">4.32x</td>
            <td class="dividend">7.20%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=1398.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (1398)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>5</a></td>
            <td class="name"><a>HSBC HOLDINGS</a></td>
            <td class="price"><bdo>HK$28.200</bdo>
                <br>
                <div class="downval"><span>-0.400</span> (<span>-1.40%</span>)</div>
            </td>
            <td class="turnover">1.20B</td>
            <td class="market">583.52B</td>
            <td class="pe">12.21x</td>
            <td class="dividend">2.78%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=0005.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (5)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>939</a></td>
            <td class="name"><a>CCB</a></td>
            <td class="price"><bdo>HK$5.020</bdo>
                <br>
                <div class="downval"><span>-0.040</span> (<span>-0.79%</span>)</div>
            </td>
            <td class="turnover">1.10B</td>
            <td class="market">1,206.89B</td>
            <td class="pe">4.36x</td>
            <td class="dividend">6.97%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=0939.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (939)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>9618</a></td>
            <td class="name"><a>JD-SW</a></td>
            <td class="price"><bdo>HK$282.200</bdo>
                <br>
                <div class="downval"><span>-6.200</span> (<span>-2.15%</span>)</div>
            </td>
            <td class="turnover">1.08B</td>
            <td class="market">883.22B</td>
            <td class="pe">-</td>
            <td class="dividend">-</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=9618.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (9618)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>1658</a></td>
            <td class="name"><a>PSBC</a></td>
            <td class="price"><bdo>HK$3.160</bdo>
                <br>
                <div class="upval"><span>+0.060</span> (<span>+1.94%</span>)</div>
            </td>
            <td class="turnover">1.05B</td>
            <td class="market">62.74B</td>
            <td class="pe">4.01x</td>
            <td class="dividend">7.23%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=1658.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (1658)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>9633</a></td>
            <td class="name"><a>NONGFU SPRING</a></td>
            <td class="price"><bdo>HK$35.150</bdo>
                <br>
                <div class="downval"><span>-2.850</span> (<span>-7.50%</span>)</div>
            </td>
            <td class="turnover">1.01B</td>
            <td class="market">174.92B</td>
            <td class="pe">-</td>
            <td class="dividend">-</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=9633.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (9633)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>1211</a></td>
            <td class="name"><a>BYD COMPANY</a></td>
            <td class="price"><bdo>HK$103.100</bdo>
                <br>
                <div class="downval"><span>-0.400</span> (<span>-0.39%</span>)</div>
            </td>
            <td class="turnover">844.11M</td>
            <td class="market">94.33B</td>
            <td class="pe">188.21x</td>
            <td class="dividend">0.06%</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=1211.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (1211)"></td>
        </tr>
        <tr class="datarow">
            <td class="code"><a>708</a></td>
            <td class="name"><a>EVERG VEHICLE</a></td>
            <td class="price"><bdo>HK$16.820</bdo>
                <br>
                <div class="downval"><span>-2.460</span> (<span>-12.76%</span>)</div>
            </td>
            <td class="turnover">789.41M</td>
            <td class="market">148.29B</td>
            <td class="pe">-</td>
            <td class="dividend">-</td>
            <td class="intraday"><img width="82" height="33" src="https://www1.hkex.com.hk/hkexwidget/chart/genchart?&amp;sym=0708.HK&amp;int=2&amp;per=1&amp;w=82&amp;h=33&amp;bottom=2&amp;mode=8&amp;tm=1601021280000" alt="Stock Chart (708)"></td>
        </tr>
    </tbody>
</table>

股票代码
名称
名义价格
营业额(港元)
市值(港元)
市盈率
股息率(%)
日内运动
909
明远云
30.700港元

0.000 (0.00%) 8.35B 57.44B - - 700 腾讯 503.500港元
-1.500 (-0.30%) 6.69B 4824.90B 46.13倍 0.24% 9988 BABA-SW 258000港元
-3.000 (-1.15%) 3.97B 5584.43B - - 3690 美团-W 港币232.000元
-6.600 (-2.77%) 3.75 B 1364.39B 547.17x - 3333 恒大 13.780港元
-1.440 (-9.46%) 2.80B 180.00B 9.59倍 5.15% 1810 小米-W 港币19.720元
-0.120 (-0.60%) 2.69B 475.78B 42.69倍 - 2318 平安 港币80.350元
-0.100 (-0.12%) 1.49B 598.41B 8.61x 2.89% 388 香港交易所 355.800港元
-1.800 (-0.50%) 1.49B 451.09B 47.50倍 1.88% 1918 苏纳克 28.950港元
-1.600 (-5.24%) 1.36B 134.94B 4.44x 4.64% 981 中芯国际 18.580港元
-0.760 (-3.93%) 1.35B 143.03B 59.55倍 - 1299 友邦保险 77.650港元
+1.000 (+1.30%)