-
Notifications
You must be signed in to change notification settings - Fork 37
/
geo.captcha-delivery.py
66 lines (54 loc) · 2.36 KB
/
geo.captcha-delivery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# IMPORTANT
# 1. Make sure to have "anticaptchaofficial" package version minimum 1.0.46
# pip install 'anticaptchaofficial>=1.0.46'
#
# 2. Proxy usage is required. Each datadome cookie is associated with a proxy and user-agent.
# Use only self-installed proxy. Shared/purchased proxies WILL FAIL.
# Instruction how to install: https://anti-captcha.com/apidoc/articles/how-to-install-squid
# Again and again people people insist they have best purchased proxies. NO YOU DO NOT!
# Absolutely recommended to read this FAQ about proxies: https://anti-captcha.com/faq/510_questions_about_solving_recaptcha_with_proxy__applies_to_funcaptcha__geetest__hcaptcha_
#
# 3. Solution might not work at first attempt. Do at least 10 attempts.
#
from anticaptchaofficial.antigatetask import *
# STOP! IMPORTANT! Read paragraph 2 above!
proxy_host = "11.11.11.11"
proxy_port = 1234
proxy_login = "login"
proxy_pass = "password"
proxies = {
'https': f"http://{proxy_login}:{proxy_pass}@{proxy_host}:{proxy_port}",
'http': f"http://{proxy_login}:{proxy_pass}@{proxy_host}:{proxy_port}"
}
solver = antibotcookieTask()
solver.set_verbose(1)
solver.set_key("API_KEY_HERE")
solver.set_website_url("https://www.allopneus.com/liste/pneu-auto?saison%5B%5D=4seasons&saison%5B%5D=ete&saison%5B%5D=hiver&page=1")
solver.set_proxy_address(proxy_host)
solver.set_proxy_port(proxy_port)
solver.set_proxy_login(proxy_login)
solver.set_proxy_password(proxy_pass)
result = solver.solve_and_return_solution()
if result == 0:
print("could not solve task")
exit()
print(result)
cookies, localStorage, fingerprint = result["cookies"], result["localStorage"], result["fingerprint"]
if len(cookies) == 0:
print("empty cookies, try again")
exit()
cookie_string = '; '.join([f'{key}={value}' for key, value in cookies.items()])
user_agent = fingerprint['self.navigator.userAgent']
print(f"use these cookies for requests: {cookie_string}")
print(f"use this user-agent for requests: {user_agent}")
s = requests.Session()
proxies = {
"http": f"http://{proxy_login}:{proxy_pass}@{proxy_host}:{proxy_port}",
"https": f"http://{proxy_login}:{proxy_pass}@{proxy_host}:{proxy_port}"
}
s.proxies = proxies
content = s.get("https://www.allopneus.com/liste/pneu-auto?saison%5B%5D=4seasons&saison%5B%5D=ete&saison%5B%5D=hiver&page=1", headers={
"Cookie": cookie_string,
"User-Agent": user_agent
}).text
print(content)