代码:
async def b(url1,url2):
url = url1 + url2
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
resp.encoding = 'UTF-8'
html = await etree.HTML(resp.text)
div = html.xpath("/html/body/div[3]/div[1]/div[1]/div/text()")
async with aiofiles.open(title,"w",encoding='UTF-8') as f:
await f.write(div)
爬取到的内容
大多数被反爬了,你输出resp.text看看网站的响应内容
如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632