我想从( https://gps24.juwentus.pl )中获取一些数据,但是这样做是登录时所必需的。我不知道如何获得授权,然后获取数据。 / strong>,我有登录名和密码。登录页面为( https://gps24.juwentus.pl/login )。
浏览后,我从下面发现登录名是“ login”,密码名是“ pass”:
<input class="loginInput" type="text" name="login" value="" placeholder="Login" id="log">
<input class="loginInput" type="password" name="pass" value="" placeholder="Hasło" id="pwd">
我认为登录页面是: “ https://gps24.juwentus.pl/openid/examples/consumer/try_auth.php” 来自:
<form method="get" action="/openid/examples/consumer/try_auth.php">
<input type="hidden" name="action" value="verify">
<input type="hidden" name="openid_identifier" value="https://juweid.juwentus.pl:9443/openid/">
<input type="submit" id="submitloginOpenid" value="Zaloguj przez OpenID" style="padding-left: 30px; white-space: normal; padding-right: 30px;" class="login">
</form>
(但是我也尝试了https://juweid.juwentus.pl:9443/openid/作为不同方式的动作)
我尝试了请求,会话,但仍获取“未登录页面”数据 (受How to "log in" to a website using Python's Requests module?
支持import requests
payload = {'login': 'good_login',
'pass': 'good_password'}
with requests.session() as c:
c.post('https://gps24.juwentus.pl/openid/examples/consumer/try_auth.php', data=payload)
response = c.get('https://gps24.juwentus.pl')
print(response.text)
我尝试过以某种方式使用'after-logging-in- cookies ',但是什么也没发生(不要把它们放在这里,因为我不知道这样是否安全)
我还尝试了其他帖子提供的 http.cookiejar,urllib.request,urllib.parse 支持的功能,但也无法管理放置位置。试图从其他职位获得帮助,但其中许多似乎已过时。 有什么建议我会犯错吗?还是此页面必须具有强大的安全性?
编辑:我将硒设为无头模式,但是它还是很慢吗?有谁知道如何使其更快?
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.binary_location = r"C:\my_path\chrome.exe"
driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver"),options=chrome_options)
driver.get("https://gps24.juwentus.pl/")
driver.find_element_by_class_name('loginInput').send_keys('***')
driver.find_element_by_name('pass').send_keys('***').send_keys(Keys.ENTER)
print(driver.find_element_by_name('something'))
也许有人知道如何抓取已打开并登录的页面?这样可以确保数据处理速度更快