新增巨量签到
This commit is contained in:
parent
5759a3c704
commit
2f117f2952
129
juliang.py
Normal file
129
juliang.py
Normal file
@ -0,0 +1,129 @@
|
||||
# 巨量 v1.00
|
||||
#
|
||||
# 每天签到获取免费代理
|
||||
#
|
||||
# 抓取请求https://mk-gateway-pro.singworld.cn/mk-outside/api/sign/toSign的请求头
|
||||
# username是账号 password是密码 wxpusher_uid是wxpusher推送uid,如果没有可不填
|
||||
# 多账号换行隔开
|
||||
# export juliang_account="username@password@wxpusher_uid"
|
||||
#
|
||||
# cron "0 0 * * *" script-path=xxx.py,tag=匹配cron用
|
||||
# const $ = new Env('巨量签到')
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import requests
|
||||
import zipfile
|
||||
import time
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.action_chains import ActionChains
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
|
||||
|
||||
def check_chromedriver():
|
||||
chromedriver_path = os.path.join(os.getcwd(), 'files', 'chromedriver')
|
||||
if sys.platform.startswith('win'):
|
||||
chromedriver_path += '.exe'
|
||||
|
||||
if os.path.exists(chromedriver_path):
|
||||
return chromedriver_path
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def download_chromedriver():
|
||||
chromedriver_url = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/120.0.6099.109/mac-arm64/chrome-mac-arm64.zip'
|
||||
# response = requests.get(chromedriver_url)
|
||||
# version_number = response.text.strip()
|
||||
|
||||
# if sys.platform.startswith('linux'):
|
||||
# chromedriver_url += f'/chromedriver_linux64.zip'
|
||||
# elif sys.platform.startswith('darwin'):
|
||||
# chromedriver_url += f'/chromedriver_mac64.zip'
|
||||
# elif sys.platform.startswith('win'):
|
||||
# chromedriver_url += f'/chromedriver_win32.zip'
|
||||
# else:
|
||||
# print('Unsupported platform')
|
||||
# return
|
||||
|
||||
response = requests.get(chromedriver_url, stream=True)
|
||||
response.raise_for_status()
|
||||
|
||||
zip_path = os.path.join(os.getcwd(), 'files', 'chrome-mac-arm64.zip')
|
||||
|
||||
with open(zip_path, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
|
||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||
zip_ref.extractall(os.path.join(os.getcwd(), 'files'))
|
||||
|
||||
os.remove(zip_path)
|
||||
|
||||
chromedriver_path = os.path.join(os.getcwd(), 'files', 'chromedriver')
|
||||
if sys.platform.startswith('win'):
|
||||
chromedriver_path += '.exe'
|
||||
|
||||
return chromedriver_path
|
||||
|
||||
|
||||
chromedriver_path = check_chromedriver()
|
||||
|
||||
if chromedriver_path is None:
|
||||
print('ChromeDriver not found. Downloading...')
|
||||
chromedriver_path = download_chromedriver()
|
||||
if chromedriver_path:
|
||||
print('ChromeDriver downloaded successfully.')
|
||||
else:
|
||||
print('Failed to download ChromeDriver.')
|
||||
else:
|
||||
print('ChromeDriver found:', chromedriver_path)
|
||||
|
||||
# 创建Chrome浏览器实例
|
||||
options = Options()
|
||||
print(chromedriver_path)
|
||||
driver = webdriver.Chrome(executable_path='/Users/codecow/Java/chromedriver', options=options)
|
||||
# 创建WebDriver对象,指定WebDriver的路径
|
||||
# driver = webdriver.Chrome(chromedriver_path)
|
||||
|
||||
# 设置浏览器窗口大小
|
||||
driver.set_window_size(1920, 1080)
|
||||
# 最大化浏览器窗口
|
||||
driver.maximize_window()
|
||||
# 设置是否显示浏览器
|
||||
driver.set_headless(True)
|
||||
# 打开网页
|
||||
driver.get('https://www.juliangip.com/user/login')
|
||||
# 等待页面加载完成
|
||||
time.sleep(2)
|
||||
|
||||
# 输入账号密码
|
||||
username = driver.find_element_by_name('username')
|
||||
password = driver.find_element_by_name('password')
|
||||
login_button = driver.find_element_by_id('login')
|
||||
|
||||
username.send_keys('18640890811')
|
||||
password.send_keys('xuyaorenpei0.0')
|
||||
|
||||
# 点击登录按钮
|
||||
login_button.click()
|
||||
|
||||
# 等待页面加载完成
|
||||
time.sleep(2)
|
||||
|
||||
# 找到class名称为free_card_2的a标签,点击
|
||||
driver.find_element_by_class_name('free_card_2').click()
|
||||
|
||||
# 定位滑块元素
|
||||
slider = driver.find_element_by_id('tcWrap')
|
||||
|
||||
# 拖动滑块
|
||||
action = ActionChains(driver)
|
||||
action.click_and_hold(slider).move_by_offset(200, 0).release().perform()
|
||||
|
||||
# 进行其他检测或操作
|
||||
time.sleep(2)
|
||||
|
||||
# 关闭浏览器
|
||||
driver.quit()
|
||||
Loading…
Reference in New Issue
Block a user