Instantly share code, notes, and snippets.

Embed
What would you like to do?
V2EX 每日任务自动领取
#!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