PythonScraping需要登录的网站

2024-10-03 06:19:47 发布

您现在位置:Python中文网/ 问答频道 /正文

是的,所以我知道如何抓取一个网站,但是我在使用python3登录一个我试图抓取的网站时遇到了问题

我已经包括了网站使用的HTML。据我所知这是需要的吗

我尝试了一个简单的解决方案,似乎应该工作,但没有(它似乎没有登录,并直接转到目标URL,跳过登录?)

Attempted Solution: https://pastebin.com/AEK6Qwnb (I've also tried a solution using RoboBrowser, but I couldn't succeed there either.) 
Website HTML: https://pastebin.com/Jp8Zpq2a   

让我知道如果这个信息是不够的,我可以尝试提供更多。 提前谢谢


Tags: httpscomurl目标网站htmlve解决方案
1条回答
网友
1楼 · 发布于 2024-10-03 06:19:47

有许多可能的解决方案,这将取决于网站,你的需要和限制以及个人喜好。然而,用selenium直接求解是可能的

from selenium import webdriver

account = 'account'
password = 'password'

browser = webdriver.get('desktop/test.html')
browser.find_element_by_id('Account').send_keys(account)
browser.find_element_by_id('password').send_keys(password)

相关问题 更多 >