-
-
Save pezy/28344f157f97a1d1569a3c6803c198e4 to your computer and use it in GitHub Desktop.
V2EX 每日任务自动领取
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python3 | |
# autoFinishedV2EXMission.py - Auto finished v2ex everyday mission. | |
import pickle | |
from selenium import webdriver | |
from selenium import common | |
from time import sleep | |
browser = webdriver.Chrome() | |
browser.get("https://www.v2ex.com") | |
try: | |
cookies = pickle.load(open('cookies.pkl', 'rb')) | |
for cookie in cookies: | |
browser.add_cookie(cookie) | |
sleep(1) | |
browser.refresh() | |
sleep(1) | |
try: | |
mission = browser.find_element_by_link_text('领取今日的登录奖励') | |
mission.click() | |
sleep(1) | |
getX = browser.find_element_by_css_selector('.super.normal.button') | |
getX.click() | |
except common.exceptions.NoSuchElementException: | |
print("Was not able to find login.") | |
except FileNotFoundError: | |
print("Was not able to find mission daily.") | |
try: | |
linkLogin = browser.find_element_by_link_text('登录') | |
linkLogin.click() | |
sleep(30) | |
pickle.dump(browser.get_cookies(), open('cookies.pkl', 'wb')) | |
print('ok!') | |
browser.close() | |
except common.exceptions.NoSuchElementException: | |
print("Was not able to find login.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment