登录

时间:2017-10-03 12:46:26

标签: python post python-requests

之前我曾多次使用过请求功能。我不知道为什么,但现在我无法登录到一个网站:

   # 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的哈希标签

1 个答案:

答案 0 :(得分:0)

我注意到你定义了redirect_url但实际上并没有使用它。您确实使用redirect_name但不在任何地方定义它。可能是你的问题吗?