Skip to content

Commit 16295f8

Browse files
committed
Add pointp.fr & swagbucks.com as real case
1 parent 09cbd97 commit 16295f8

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

examples/real-cases/pointp.fr.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Date of last verification: June 28, 2019
2+
from os import environ
3+
import time
4+
from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask
5+
6+
api_key = environ['KEY']
7+
invisible_captcha = True
8+
site_key_pattern = 'data-sitekey="(.+?)"'
9+
url = 'https://www.pointp.fr/)'
10+
client = AnticaptchaClient(api_key)
11+
12+
def get_token(website_url, site_key, invisible):
13+
task = NoCaptchaTaskProxylessTask(
14+
website_url=website_url,
15+
website_key=site_key,
16+
is_invisible=invisible
17+
)
18+
job = client.createTask(task)
19+
job.join()
20+
return job.get_solution_response()
21+
22+
23+
def process(driver):
24+
driver.get(url)
25+
driver.switch_to.frame(0)
26+
site_key = driver.find_element_by_class_name('g-recaptcha').get_attribute('data-sitekey')
27+
print("Found site-key", site_key)
28+
print("Send challenge")
29+
current_frame_url = driver.execute_script('return document.location.href')
30+
token = get_token(current_frame_url, site_key, False)
31+
print("Form submitted")
32+
driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML='{}';".format(token))
33+
driver.execute_script("captchaCallback()")
34+
time.sleep(10)
35+
return driver.title
36+
37+
38+
if __name__ == '__main__':
39+
from selenium.webdriver import Firefox
40+
from selenium.webdriver.firefox.options import Options
41+
42+
options = Options()
43+
driver = Firefox(firefox_options=options)
44+
assert 'Error 404 | Point.P' in process(driver)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Date of last verification: June 28, 2019
2+
import re
3+
from os import environ
4+
5+
from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask
6+
7+
api_key = environ['KEY']
8+
invisible_captcha = True
9+
url = 'https://www.swagbucks.com/p/login'
10+
client = AnticaptchaClient(api_key)
11+
12+
13+
def get_token(website_url, site_key, invisible):
14+
task = NoCaptchaTaskProxylessTask(
15+
website_url=website_url,
16+
website_key=site_key,
17+
is_invisible=invisible
18+
)
19+
job = client.createTask(task)
20+
job.join()
21+
return job.get_solution_response()
22+
23+
24+
def process(driver):
25+
driver.get(url)
26+
site_key = re.search("captchaSitekey = '(.+?)'",driver.page_source).group(1)
27+
print("Found site-key", site_key)
28+
print("Send challenge")
29+
token = get_token(driver.current_url, site_key, invisible_captcha)
30+
print("Received challenge-response")
31+
driver.find_element_by_xpath('//*[@id="sbxJxRegEmail"]').send_keys('[email protected]')
32+
driver.find_element_by_xpath('//*[@id="sbxJxRegPswd"]').send_keys('password')
33+
driver.find_element_by_xpath('//*[@id="loginBtn"]').click()
34+
print("Form submitted")
35+
driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML='{}';".format(token))
36+
driver.execute_script("document.getElementById('loginForm').submit()")
37+
return driver.find_element_by_xpath('//*[@id="divErLandingPage"]').text
38+
39+
40+
if __name__ == '__main__':
41+
from selenium.webdriver import Firefox
42+
from selenium.webdriver.firefox.options import Options
43+
44+
options = Options()
45+
# options.add_argument('-headless')
46+
driver = Firefox(firefox_options=options)
47+
assert 'Incorrect Email/Password Combination' in process(driver)

0 commit comments

Comments
 (0)