Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
lintCode反爬虫登陆
# -*- coding=utf-8 -*-
import requests
agent = 'Mozilla/5.0(Windows NT 6.1; rv:59.0) Gecko/20100101 Firefox/59.0'
referer = 'https://www.lintcode.com/accounts/signin/'
Token = 'KPHxDihzU8OiLudC3DsDyhVK78HO657d'
headers = {'User-Agent': agent, 'Referer': referer, 'X-CSRFToken': Token}
post_url = 'https://www.lintcode.com/accounts/signin/'
s = requests.Session()
s.keep_alive = False
requests.adapters.DEFAULT_RETRIES = 5
r = s.get(post_url, headers=headers, allow_redirects=True)
cookies = dict(__atuvc = '4|17',
__cfduid = 'd0a8707338d055a45f8d541e4f444e6ee1524576620',
_ga = 'GA1.2.566960194.1524577455',
AWSALB ='k9LyEp19nKW1DLV0i084hRnrwApXexFIvpyjbDAJX3ix5VkE2qma12far5eD3foQPS/uQoZ76GdfTCznF12TyjEk31X7T9O17vNDn7+uLdKYtFRX0hNfD9YMazDb',
csrftoken ='KPHxDihzU8OiLudC3DsDyhVK78HO657d',
language_code = 'zh-cn',
sessionid = 'c78nwrqpmuku2xfj8f50l0jvgjvfqx07')
post_data = {'password': 'XXXXXXX', 'remember': '0', 'username_or_email': 'XXXXXXXXXXXXXX'}
r = s.post(post_url, data=post_data, headers=headers, cookies=cookies, allow_redirects=True)
print r.content
print r.status_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment