[英]Logging in with requests post
我以前多次使用請求發布功能。 我不知道為什么,但是現在我無法登錄一個網站:
# Import
from requests import Session
from bs4 import BeautifulSoup
# Core settings
HEADERS = {
"User-Agent": "Mozilla/5.0"}
s = Session()
response = s.get("https://suite.searchmetrics.com/en/auth/login", headers=HEADERS)
soup = BeautifulSoup(response.text, "lxml")
redirect_url = soup.select('input[id="id_redirect_data"]')[0].get("value")
data = {"redirect_url": redirect_url,
"mail": "aaa@gmail.com",
"password": "abcfeFD"}
s.post("https://suite.searchmetrics.com/en/auth/authenticate", data=data, headers=HEADERS)
然后,當我嘗試:
content_url = "https://suite.searchmetrics.com/en/research?url=wsj.com"
response = s.get(content_url, headers=HEADERS)
soup1 = BeautifulSoup(response.text, "lxml")
print(soup1.prettify())
我找不到屬於highchart的哈希標簽
我注意到您定義了redirect_url,但實際上並未使用它。 您確實使用過redirect_name,但未在任何地方定義它。 可能是您的問題嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.