diff --git a/10.selenium/zhifubao/selenium_so_chrome.py b/10.selenium/zhifubao/selenium_so_chrome.py new file mode 100644 index 00000000..eba10e8f --- /dev/null +++ b/10.selenium/zhifubao/selenium_so_chrome.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- +#------------------------------------------------------------------------- +# 程序:selenium_so.py +# 版本:0.1 +# 作者:ly +# 日期:编写日期2016/11/23 +# 语言:Python 2.7.x +# 操作:python selenuium.py +# 功能:结合crontab定时启动每天自动登录so网站,刷银牌用 +#------------------------------------------------------------------------- + +import sys +import time + +from selenium import webdriver +from selenium.webdriver.common.keys import Keys + +# 中文编码设置 +reload(sys) +sys.setdefaultencoding('utf-8') +Type = sys.getfilesystemencoding() + +# 加载内核 +#driver = webdriver.PhantomJS() +driver = webdriver.Chrome() +# 发起请求 +print 'beging_0' +url ='https://shenghuo.alipay.com/send/payment/fill.htm' +# driver.get("http://lbsyun.baidu.com/skins/MySkin/resources/iframs/heightAccApi.html") +# driver.get("https://s.m.taobao.com/h5?event_submit_do_new_search_auction=1&_input_charset=utf-8&topSearch=1&atype=b&searchfrom=1&action=home%3Aredirect_app_action&from=1&sst=1&n=20&buying=buyitnow&q=%E7%9A%AE%E8%A3%A4%E5%A5%B3") +driver.get(url) +# http://lbsyun.baidu.com/index.php?title=webapi/high-acc-ip + +# 获取用户名框并输入 +print 'beging_1' +elem = driver.find_element_by_xpath('//*[@id="J-input-user"]') +elem.send_keys("@qq.com") +time.sleep(1) +elem = driver.find_element_by_xpath('//*[@id="password_rsainput"]') +elem.send_keys("") +time.sleep(1) +elem = driver.find_element_by_xpath( + '//*[@id="J-login-btn"]').click() +time.sleep(5) + +elem = driver.find_element_by_xpath('//*[@id="ipt-search-key"]') +elem.send_keys("") + +time.sleep(1) +elem = driver.find_element_by_xpath( + '//*[@id="amount"]').click() +time.sleep(1) +# 获取密码框并输入 +# print 'beging_2' +# elem = driver.find_element_by_xpath( +# '//*[@class="desc_page_box normal"]').click() +# elem.send_keys("**")desc_page_box normal +# 通过回车键进行登录 +# print 'beging_3' +# elem.send_keys(Keys.RETURN) + +# time.sleep(10) +# js1 = 'return document.body.scrollHeight' +# js2 = 'window.scrollTo(0, document.body.scrollHeight)' + +# old_scroll_height = 0 +# while(driver.execute_script(js1) > old_scroll_height): +# old_scroll_height = driver.execute_script(js1) +# driver.execute_script(js2) +# time.sleep(3) +# name = '' + time.ctime().replace(' ', '-') + '.png' +# driver.save_screenshot(name) +# 保存页面截图和源码 +name = '' + time.ctime().replace(' ', '-') + '.png' +driver.save_screenshot(name) +#f = open(name_html.encode('utf-8'),'w') +# f.write(driver.page_source) +# f.close() + +# print driver.page_source.encode('utf8') + +time.sleep(5) + +# driver.quit() +# elem.clear() +# time.sleep(10) +driver.close()