I try to run the code below
!/usr/bin/python2.7
import json, urllib
query = '"Vibrio cholerae O1"[Organism]"'
params = {'db':'sra', 'term':query, 'usehistory':'y', 'retmode':'json',}
url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi'
stream = urllib.urlopen(url, urllib.urlencode(params))
answer = json.loads(stream.read())
webenv = answer["esearchresult"]["webenv"]
query_key = answer["esearchresult"]["querykey"]
params = {'db':'sra', 'save':'efetch', 'rettype':'runinfo', 'WebEnv':webenv, 'query_key':query_key,} url = 'http://trace.ncbi.nlm.nih.gov/Traces/sra/sra.cgi' outfile = 'runinfo.csv' urllib.urlretrieve(url, data=urllib.urlencode(params), filename=outfile)
#
Up to line answer = json.loads(stream.read()) It prompts error :
answer = json.loads(stream.read()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded
Is there any solution or suggestion, it would be highly appreciated.