Python 使用请求发布验证码应答
因此,我有这个验证码,我需要解决和发送请求后的方法,但我不知道如何开始响应Python 使用请求发布验证码应答,python,post,captcha,python-requests-html,Python,Post,Captcha,Python Requests Html,因此,我有这个验证码,我需要解决和发送请求后的方法,但我不知道如何开始响应 <form name="captchaForm" action="/captcha/eval.do" onsubmit="document.captchaForm.hash.value=window.location.hash;"> <img id="captchaTag" src="/captch
<form name="captchaForm" action="/captcha/eval.do" onsubmit="document.captchaForm.hash.value=window.location.hash;">
<img id="captchaTag" src="/captcha/captcha.do?id=132.204.251.80">
<audio id="audioCaptchaTag" style="display: none;" preload="auto" onplay="$('#captchaResponse').focus();" controls="" src="/captcha/audioCaptcha.do?id=132.204.251.80&lang=fr&cacheBuster=1aca7bbb658bf40435965772b3343124f" type="audio/wav"></audio>
<button id="toggleAudio" alt="Click here to access the audible captcha" type="button" onclick="$('#captchaTag').toggle(); $('#audioCaptchaTag').toggle(); $('#captchaResponse').focus(); "><i class="fas fa-headphones"></i></button>
<input autocapitalize="none" id="captchaResponse" style="margin: 0;" type="text" name="jcaptcha" value="" autofocus="">
<input type="hidden" name="path" value="/fr/qc/qcrdl/doc/2009/2009canlii97762/2009canlii97762.html">
<input type="hidden" name="queryString" value="">
<input type="hidden" name="hash" value="">
<input type="hidden" name="id" value="132.204.251.80">
<input type="submit" value="ok">
</form>
我是在努力寻找坎利的时候找到这个答案的。我还没有设法解决验证码问题,但发现通过webdriver浏览网页时,抓取验证码的次数大约减少了20倍。通过每次点击验证码时切换我的IP地址,我成功地将抓取时间提高到100%。这里有一些代码,如果你能从中获得灵感的话:我是在努力寻找canlii的时候发现这个答案的。我还没有设法解决验证码问题,但发现通过webdriver浏览网页时,抓取验证码的次数大约减少了20倍。通过每次点击验证码时切换我的IP地址,我成功地将抓取时间提高到100%。这里有一些代码,如果你能从中获得灵感的话:嘿,谢谢!我终于做到了。使用含硒的Tor也对我有帮助。很想知道你在刮Canlii的哪一部分。嘿,谢谢!我终于做到了。使用含硒的Tor也对我有帮助。很想知道你在刮Canlii的哪一部分。
import requests
from bs4 import BeautifulSoup
import cv2
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Max-Age': '3600',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'
}
session = requests.Session()
req = session.get(url, headers=headers)
soup = BeautifulSoup(req.content, "lxml")
captcha = soup.find("form", {"name": "captchaForm"})
if captcha is None:
# Do stuff
else:
print(".......... YOU'VE HIT A CAPTCHA")
capatchaImage = soup.find("img",{"id":"captchaTag"}).get("src")
cv2.imshow("captcha", captchaImage)
cv2.waitKey()
captchaInput = input("Please enter captcha: "))
continue