【问题标题】:Python request.get not getting all <div>Python request.get 没有得到所有 <div>
【发布时间】:2019-10-10 16:45:17
【问题描述】:

我正在使用 chrome 的开发人员页面向https://racing.appledaily.com.hk/race-day/race-position?raceDay=1865&race=15632 发出获取请求,我可以看到完整的 html 页面。但是,当我发出 get 请求时,python 只返回部分 h​​tml。

HTML:

<html class="gr__racinng_applledaily_com_hk" style='overflow: initial;">
<head> ... </head>
<body data-gr-c-s-loaded="true">
<!-- Google Tag Mananger (noscript) -->
<noscript> ...</noscript>
<!-- End Google Tag Mananger (noscript) -->
<div data-v-6223d6a8 id="app" class="web"> ... </div>
</body>
</html>

&lt;div data-v-6223d6a8 id="app" class="web"&gt; ... &lt;/div&gt; 部分丢失

使用的代码:

content = request.get('https://racing.appledaily.com.hk/race-day/race-position?raceDay=1865&race=15632')

【问题讨论】:

    标签: python get request


    【解决方案1】:

    Request 从源中获取 HTML。当您使用检查器时,您会看到完整的 HTML,因为您的浏览器会呈现 HTML 的其余部分。要获得完整的 HTML 查看 Scrapy Splash 或 Selenium。

    【讨论】:

      猜你喜欢
      • 2016-04-21
      • 2020-11-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多