#!/usr/bin/env python
#coding:utf-8

from ghost import Ghost, Session
import time
if __name__ == '__main__':
    gh = Ghost()
    se = Session(gh, display=True)
    se.open("https://www.baidu.com/")
    se.show()  #完成输入后要刷新
    se.fill("#kw", "hello world")
    se.click("#su", btn=0)
    se.show()  #完成输入后要刷新
    time.sleep(10)
Beispiel #2
0
    se.set_field_value('#ticket', vcode)
    se.sleep(0.1)
    se.click('#submit', expect_loading=True)


login(username, password)

    
    
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')
#!/usr/bin/env python
#coding:utf-8

from ghost import Ghost, Session
import time
if __name__ == '__main__':
    gh = Ghost()
    se = Session(gh, display = True)
    se.open("https://www.baidu.com/")
    se.show()#完成输入后要刷新
    se.fill("#kw","hello world")
    se.click("#su",btn=0) 
    se.show()#完成输入后要刷新
    time.sleep(10)