在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ python 獲取網(wǎng)頁內(nèi)容為空

python 獲取網(wǎng)頁內(nèi)容為空

準備做個檢測新股申購的iphone widget(下滑屏幕頂就出來的那個),widget方面pytonista里面有案例應(yīng)該不難

目標網(wǎng)址:
http://m.data.eastmoney.com/x...

網(wǎng)頁源代碼分析
json 內(nèi)容 搜 defaultData
另一個是 div clasa= day-list
試了兩個返回都是空

下面是代碼

import requests
import json
import html5lib
from bs4 import BeautifulSoup as BS

headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'}

url = 'http://m.data.eastmoney.com/xg/xgsg.html'

r = requests.get(url, headers = headers)
r.encoding = 'UTF-8'
soup = BS(r.text, 'html5lib')

div = soup.find_all('div day-list')
回答
編輯回答
朕略萌
$.ajax({
                url: '/XG/XgsgList',
                type: 'GET',
                data: {
                    'pagesize': 30, 'page': countNum
                },
                beforeSend: function () {
                    //請求前調(diào)用函數(shù),如果它返回 false ,請求將被取消。
                    loadingDiv.showThis('see_more');
                },
                dataType: "json",
                success: function (data) {
                    LoadTable(data, sgUrlArr, onload)
                },
                error: function () {
                    $("#see_more").hide();
                    $("#xgsg").append('<div class="day-list"><table><tbody><tr><td colspan="4">數(shù)據(jù)加載失敗</td></tr></tbody></table></div>');
                }
            });

因為他是在這里加載的
你最開始爬蟲的html里沒有day-list

<div id="xgsg" class="tab-panel active">
        <table class="tab-header">
            <tr>
                <td class="pd10 w19b"><div class="lh20 ">名稱</div><div class="lh20 ">申購碼</div></td>
                <td class="pd10 w19b"><div class="lh20 ">網(wǎng)上</div><div class="lh20 ">發(fā)行數(shù)</div></td>
                <td class="pd10 w24b"><div class="lh20 ">發(fā)行價</div><div class="lh20 ">市盈率</div></td>
                <td class="pd10 w19b">申購上限</td>
                <td class="pd10 w19b">狀態(tài)</td>
            </tr>
        </table>
    </div>
2018年9月21日 20:19