SuLab / biogps_dataset

BioGPS.org dataset & dataset loading code repository
http://biogps.org/
0 stars 2 forks source link

switch to use "requests" and "requests_cache" modules to call web services #4

Open JTFouquier opened 8 years ago

JTFouquier commented 8 years ago

http://docs.python-requests.org/en/latest/

https://github.com/reclosedev/requests-cache

"requests" is a module much better than build-in urllib and urllib2.

"request_cache" provides a cache for requests, regardless the actual caching headers. Very useful for both development and actual data-loading.

Example code:

#!python

import requests
import requests_cache

requests_cache.install_cache('arrayexpress_cache')

res = requests.get('http://www.ebi.ac.uk/arrayexpress/json/v2/experiments/E-GEOD-19279')
data = res.json()

res = requests.get('http://www.ebi.ac.uk/arrayexpress/files/E-GEOD-19279/E-GEOD-19279.sdrf.txt')
data = res.text()

JTFouquier commented 8 years ago

done


Original comment by: jin_xuefeng

JTFouquier commented 8 years ago

done


Original comment by: jin_xuefeng