我想从serp中提取总结果数。但响应 html 源代码 (https://pastebin.com/eizmaNTQ) 不包含任何结果编号。
我搜索了很多其他类似的帖子,但它们是很久以前发布的,没有帮助。
我需要使用 js 渲染来达到我的目的吗?谢谢。
import httpx
import asyncio
async def main(keyword: str):
async with httpx.AsyncClient() as client:
response = await client.get(f"https://www.google.com/search?q={keyword}")
return response.content.decode("latin1")
但是你的 html 响应是什么样的?
您的请求是否使用了 User-Agent HTTP 标头?
你的项目需要Python吗?
在JavaScript中可以通过以下方式实现:
var result = document.querySelector("#result-stats").textContent
console.log(result)