Created
August 2, 2015 02:08
-
-
Save yiwenlu66/f6185e2e39e9660d9539 to your computer and use it in GitHub Desktop.
NE2X 每日任务脚本
This file contains hidden or 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
import requests | |
from bs4 import BeautifulSoup | |
# Fill in your account here | |
EMAIL = "" | |
PASSWD = "" | |
session = requests.Session() | |
main_url = "http://ne2x.com/" | |
main = session.get(main_url) | |
main_soup = BeautifulSoup(main.text, "html.parser") | |
token = main_soup.find("input", {"type": "hidden", "name": "_token"})["value"] | |
auth_info = {"email": EMAIL, "password": PASSWD, "button": None, "_token": token} | |
auth_url = "http://ne2x.com/auth/login" | |
page = session.post(auth_url, data=auth_info) | |
page_soup = BeautifulSoup(page.text, "html.parser") | |
csrf_token = page_soup.find("meta", {"name": "csrf-token"})["content"] | |
sign_url = "http://ne2x.com/daily_mission" | |
headers = {"X-CSRF-TOKEN": csrf_token, "X-Requested-With": "XMLHttpRequest"} | |
result = session.post(sign_url, headers=headers) | |
print(result.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment