我尝试用漂亮的汤黄色突出显示的值“entry.1661051188”刮擦,但我可以以某种方式访问它。使用 hidden_tags 我无法访问它。也许有人有一个想法,我可以通过...访问它
from bs4 import BeautifulSoup
import requests
import random
source = requests.get("https://docs.google.com/forms/d/e/1FAIpQLSfRS67JXAG8XXeeXM5Yz7-vA5Lp7-IKuiCHNANR0WLWo-qCxw/viewform")
src = source.content
soup = BeautifulSoup(source.text,"html.parser")
s = requests.Session()
hidden_tags = soup.find("input")
print(hidden_tags)
答案 0 :(得分:0)
要获取隐藏的输入标签,您可以使用 type
。像这样
hidden_tags = soup.find_all('input', {'type':'hidden'})
但是你为什么用这个
src = source.content
soup = BeautifulSoup(source.text,"html.parser")
s = requests.Session()
如果要使用会话,则不需要在调用 url 后创建 session
,然后在调用 url 之前执行此操作,然后将其用作,
session = req.session()
src = session.get(URL)
如果您想保留 cookie 和标头并想进行多次调用,则仅使用 session.
创建额外的变量 src = source.content
只是为了保存源不是最佳尝试直接在解析器中使用它