Python request.get无法获取所有<div>

2024-06-26 02:13:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在通过chrome的开发者页面向https://racing.appledaily.com.hk/race-day/race-position?raceDay=1865&race=15632发出get请求,我可以看到完整的html页面。然而,当我发出get请求时,python只返回html的一部分

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>

缺少<div data-v-6223d6a8 id="app" class="web"> ... </div>部分

使用的代码:

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

Tags: httpsdivcomdatagethtmlpositionclass
1条回答
网友
1楼 · 发布于 2024-06-26 02:13:32

请求从源代码获取HTML。使用inspector时,您会看到完整的HTML,因为浏览器会呈现HTML的其余部分。获取Scrapy Splash或Selenium的完整HTML外观

相关问题 更多 >