Skip to content

Commit 2f6ad0f

Browse files
committed
Add entertainow.com example
1 parent 16295f8 commit 2f6ad0f

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Date of last verification: July 1, 2019
2+
from os import environ
3+
import re
4+
import time
5+
from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask
6+
from six.moves.urllib_parse import parse_qs
7+
from six.moves.urllib_parse import urlparse
8+
9+
api_key = environ['KEY']
10+
invisible_captcha = False
11+
url = 'https://adserver.entertainow.com/zmgzpn.html?s=enc&rid=-502853179$154368999$vpj2QVo1SbPSpZhcqLWcKA&hsh=a705c915efcf57321a9c584ec750b03b7cf4a07a822497de6f52dddd4d1f4545&uid=58368914&sn=32768&returnUrl=https%3A%2F%2Fpf.entertainow.com%2Ff%2Fp%2Fenter%3Fplid%3D5b20522f7591fdc1418b4568%24154368956%24jPJ*pdhbyWqYdXEjWpMD.w%26euid%3D5d16abe7d50308a73e35ca76%24154368956%24oytInltQjMOz36lDm6Tt5A%26rock%3D%257B%2522fid%2522%253A%2522561544a67591fda2598b4567%2522%252C%2522puid%2522%253A%252258368914%2522%257D%26paper%3Dpq4pNV2wBaQ6jy6jsg29qWKIWEM2lgnVzrnOftOWOtWLfKu1CTN7vMxoYDsQRVETJg0UuF38SfDsIw2z8klV951ItmelQ_dXvPhNXQ5wPJkcHsRtSfXpeVzghsV3q6vjhnHVJDRu6CHuLhcGm95QPrn9VV88dpdhWDZUbUCxS7gmDAKzvc-9jeTNT4pyUd-cZRcA3Fw--6u68SRB5MdJLrhnHa8A7i_Hraya4skuUvYVw_lmT6G_MFpqCh5H-a63hxna8PotM5E%26hasRedesign%3D0%26urrMet%3Dnull%26sig%3D4026719678a6045a7f2e054c2bd1f7ee%26encl%3D370900474%26trkid%3D1108961&iasHash=OPDBQgYbFckkA3it6WJ/iQ==&forensiqHash=572919d4acd58ea12e0124b4ba4c5327&encl=370900474&plid=5b20522f7591fdc1418b4568&fid=561544a67591fda2598b4567'
12+
client = AnticaptchaClient(api_key)
13+
14+
15+
def get_token(website_url, site_key, invisible):
16+
task = NoCaptchaTaskProxylessTask(
17+
website_url=website_url,
18+
website_key=site_key,
19+
is_invisible=invisible
20+
)
21+
job = client.createTask(task)
22+
job.join()
23+
return job.get_solution_response()
24+
25+
26+
def process(driver):
27+
driver.get(url)
28+
# driver.switch_to.frame(0)
29+
iframe_url = driver.find_element_by_xpath("//iframe[starts-with(@src, 'https://www.google.com/recaptcha/')]").get_attribute('src')
30+
site_key = parse_qs(urlparse(iframe_url).query)['k'][0]
31+
# import ipdb; ipdb.set_trace();
32+
print("Found site-key", site_key)
33+
print("Send challenge")
34+
current_frame_url = driver.execute_script('return document.location.href')
35+
token = get_token(current_frame_url, site_key, False)
36+
import ipdb; ipdb.set_trace()
37+
callback_function = re.search('(CAPTCHA_IMMEDIATE.+?),', driver.page_source).group(1)
38+
driver.execute_script(
39+
"document.getElementById('g-recaptcha-response').innerHTML='{}';".format(token)
40+
)
41+
driver.execute_script("{}()".format(callback_function))
42+
time.sleep(10)
43+
return driver.page_source
44+
45+
46+
if __name__ == '__main__':
47+
from selenium.webdriver import Firefox
48+
from selenium.webdriver.firefox.options import Options
49+
50+
options = Options()
51+
assert 'Close Window' in process(Firefox(firefox_options=options))

0 commit comments

Comments
 (0)