簡體   English   中英

使用驗證碼登錄Python Web Scraping

[英]Python Web Scraping login with captcha

我必須使用網絡抓取功能登錄到網頁上,但同時也需要解決驗證碼。 我能夠解決驗證碼。 我在繼續會話時遇到問題。

session = requests.Session()
html = session.get(url).content
soup = bs(html, 'html.parser')
name = soup.find('input', attrs={'id':some_id1})
pass = soup.find('input', attrs={'id':some_id2})
captcha = soup.find('input', attrs={'id':some_id3})

在此之后,我解決了驗證碼。

credentials = {
        some_id1 : username,
        some_id2 : password,
        some_id3 : captchatext,
    }

我不知道如何繼續進行會議,我想出了下面的代碼,但它不起作用。 我也一直在尋找各種答案,但都沒有用。

session.post(url, data=credentials)
response = session.get(url).content
soup2 = bs(response, 'html.parser')

我需要從成功登錄后打開的URL中獲取數據。

使用瀏覽器的開發工具來檢查對該特定網址執行的請求。 您將找到一個請求URL,您必須將該URL與有效負載(即憑據)一起傳遞到post方法中。 然后您將獲得正確的響應。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM