我一直在尝试使用 python 做一个请求表单,但我被 recaptcha 阻止了。
我需要 g-recaptcha-response 来填写整个表格,但我不知道如何获取它。
我一直在尝试,但我不知道我在做什么。我对验证码一无所知。
这是我的代码:
url = url_add_to_cart
c.get(url)
c.post(url, data=add_to_cart_FORM, headers={"Refered": link_article})
page = c.get(link_article)
if (page.status_code == requests.codes.ok):
print ("ok")
else:
print ("not ok")
url1 = "https://www.supremenewyork.com/checkout.json"
c.get(url)
t = requests.get('http://ip.42.pl/raw')
tt = BeautifulSoup(t.text, 'html.parser')
ip = tt.text
print (ip)
page = c.get(link_checkout)
soup = BeautifulSoup(page.text, 'html.parser')
find_class = soup.find(class_='g-recaptcha')
get_captcha_token = find_class.get('data-sitekey')
try:
content = requests.post(
'https://www.google.com/recaptcha/api/siteverify',
data={
'secret': RECAPTCHA_SECRET,
'response': get_captcha_token,
'remoteip': ip
}
).content
except:
print ("fail")
print (get_captcha_token)
c.post(url, data=payload_FORM, headers={"Refered": link_checkout})
page = c.get(link_checkout)
# page_to_print_for_test = BeautifulSoup(page.text, 'html.parser')
# print (page_to_print_for_test.prettify())
if (page.status_code == requests.codes.ok):
print ("ok")
else:
print ("not ok")
这是验证码的源代码:
如果您需要更多信息,我会添加所有内容!非常感谢您。
这是完成我的代码的最后一件事。(我需要正确编码^^)