Download affy annotation file with python
I want to download an affymetrix annotation file. But it needs to log in first.
The log in page is https://www.affymetrix.com/estore/user/login.jsp The file I want to download is: http://www.affymetrix.com/Auth/analysis/downloads/na32/genotyping/GenomeWideSNP_6.na32.annot.db.zip
I have try some method but I cannot figure it out.
#
from requests import session
payload = {
'action': 'login',
'username': 'username', #This part should be changed
'password': 'password' #This part should be changed
}
with session() as c:
c.post('https://www.affymetrix.com/estore/user/login.jsp', data=payload)
request = c.get('http://www.affymetrix.com/Auth/analysis/downloads/na32/genotyping/GenomeWideSNP_6.na32.annot.db.zip')
print request.headers
print request.text
# I also try urllib2,
import urllib, urllib2, cookielib
username = 'username'
password = 'password'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'username' : username, 'password' : password})
opener.open('https://www.affymetrix.com/estore/user/login.jsp', login_data)
resp = opener.open('http://www.affymetrix.com/Auth/analysis/downloads/na32/genotyping/GenomeWideSNP_6.na32.annot.db.zip')
resp.read()
Here's the URL that the information is getting posted to.
https://www.affymetrix.com/estore/user/login.jsp?_DARGS=/estore/user/login.jsp
here is the information that is being posted.

上一篇: 如何保存Python交互式会话?
下一篇: 用python下载亲爱的注释文件
