fastapi+playwright爬取google搜索1-3页的关键词返回json
1,playwright无头
2,代理池随机获取代理ip
3,随机浏览行为,随机页面滚动
4,启用stealth模式
5,随机延时搜索
from fastapi import FastAPI, HTTPException
from fastapi.responses import JSONResponse
import asyncio
from concurrent.futures import ThreadPoolExecutor
from google3 import GoogleScraper
from playwright.sync_api import sync_playwright
from playwright.sync_api import expect
import time
import random
# 在原有代码最后添加以下 FastAPI 集成部分
# -------------------------------------