Created
September 5, 2015 11:52
-
-
Save anonymous/fef78cdd388a3567f788 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import requests | |
from pyquery import PyQuery as pq | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36', | |
'Origin': 'http://www.icbc.com.cn', | |
'Referer': 'http://www.icbc.com.cn/ICBCDynamicSite2/other/rmbdeposit.aspx', | |
'Host': 'www.icbc.com.cn', | |
} | |
def get_viewstate(): | |
res = requests.get('http://www.icbc.com.cn/ICBCDynamicSite2/other/rmbdeposit.aspx',headers=headers).content | |
viewstate = pq(res)("#__VIEWSTATE").attr.value | |
return viewstate | |
def get_rate(date): | |
data = { | |
'__EVENTTARGET':'Sel_Date', | |
'__EVENTARGUMENT':'', | |
'__LASTFOCUS':'', | |
'__VIEWSTATE':get_viewstate(), | |
'Sel_Date':date, | |
} | |
r = requests.post('http://www.icbc.com.cn/ICBCDynamicSite2/other/rmbdeposit.aspx',headers=headers,data=data) | |
return r.content | |
if __name__ == '__main__': | |
print get_rate('2015-05-11') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment