|
楼主 |
发表于 2021-8-17 08:53:56
|
显示全部楼层
- # 导包
- from selenium import webdriver
- import time
- import requests
- from lxml import etree
- # 获取[浏览器]的实例化对象
- 浏览器对象 = webdriver.Chrome()
- 浏览器对象.maximize_window()
- # 使用浏览器打开网址
- 浏览器对象.get("https://club.ccmnn.com/")
- # 定位并输入用户名
- 账号 = input('请输入账号:')
- 用户名 = 浏览器对象.find_element_by_id('ls_username')
- 用户名.clear()
- 用户名.send_keys(账号)
- # 定位并输入密码 id是唯一的
- mima = input('请输入密码:')
- 密码 = 浏览器对象.find_element_by_id('ls_password')
- 密码.clear()
- 密码.send_keys(mima)
- # 定位登录按钮并点击
- 登录 = 浏览器对象.find_element_by_xpath("//*[@id='lsform']/div/div[1]/table/tbody/tr[2]/td[3]/button/em")
- time.sleep(2)
- 登录.click()
- # 停留10秒钟,人工验证
- time.sleep(10)
- url = 浏览器对象.current_url
- ua = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"}
- cookies = 浏览器对象.get_cookies()
- cookies_dict= {}
- for i in cookies:
- cookies_dict[i['name']] = i['value']
- respon = requests.get(url=url,headers = ua,cookies=cookies_dict).text
- jiexi = etree.HTML(respon)
- jifen = jiexi.xpath('//*[@id="extcreditmenu"]/font/text()')
- 浏览器对象.get("https://club.ccmnn.com/plugin.php?id=hux_miner:hux_miner")
- shuaxin = 浏览器对象.find_element_by_id('shouyi_re')
- #一定要停留片刻,不然总报错
- time.sleep(2)
- shuaxin.click()
- time.sleep(2)
- lingqu = 浏览器对象.find_element_by_id('shouyi_show')
- time.sleep(2)
- lingqu.click()
- time.sleep(2)
- 浏览器对象.find_element_by_id('fwin_dialog_close').click()
复制代码 |
|