Beispiel #1
0
    
url = 'https://trade.cgws.com/cgi-bin/user/Login'
se.open(url)
# username
se.set_field_value('#fundAccount', username)
# password
se.fire('#normalpassword', 'focus')
se.show()
html = se.content
soup =  BeautifulSoup(html, "html.parser")
keys = soup.select('tbody > tr > td')
key_list = []
for key in keys:
    key_list.append(key.text)

for i in password:
    m = (key_list.index(i) // 4) + 1
    n = (key_list.index(i) % 4) + 1
    se.click('tbody > tr:nth-child(%s) > td:nth-child(%s)' % (m, n))

#se.click('tbody > tr:nth-child(2) > td:nth-child(2)')
se.capture_to('s/vcode.png', selector='#ticketImg')
image = Image.open('s/vcode.png')
vcode = pytesseract.image_to_string(image)
se.set_field_value('#ticket', vcode)
#se.click('#submit')
    
    


Beispiel #2
0
ghost = Ghost()
USERAGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"

with ghost.start():
    session = Session(ghost, download_images=False, display=True, user_agent=USERAGENT, viewport_size=(800, 600))
    page, rs = session.open("https://m.facebook.com/login.php", timeout=120)
    assert page.http_status == 200

    session.evaluate("""
    document.querySelector('input[name="email"]').value = '*****@*****.**'
    document.querySelector('input[name="pass"]').value = 'wikipedia150101facebook';
    """)

    session.evaluate("""document.querySelector('input[name="login"]').click();""",
                 expect_loading=True)

    """
    import codecs

    with codecs.open('fb.html', encoding='utf-8', mode='w') as f:
       f.write(session.content)
    """

    # session.save_cookies('fbookie')
    session.capture_to(path='fbookie.png')

    # gracefully clean off to avoid errors
    session.webview.setHtml('')
    session.exit()