response = self.get(uri=url, timeout=9)
# 获取响应的html文件
soup = BeautifulSoup(response.text, 'lxml')
# 格式化html文件
soup.prettify()
#拉取包含登陆id的部分,并转成字符串
idStr1 = f"{soup.script.string}"
#截取需要的id值
idStr1 = idStr1[:idStr1.rfind('\",\"name\":\"密码认证')]
idStr1 = idStr1[(idStr1.rfind('\"id\":\"')+6):]
return idStr1
http响应为html,python截取想要的内容
最新推荐文章于 2023-08-29 14:56:26 发布