Skip to content

Instantly share code, notes, and snippets.

@kozo2
Created December 17, 2014 09:50
Show Gist options
  • Save kozo2/40849c79db9db3a7fe1d to your computer and use it in GitHub Desktop.
Save kozo2/40849c79db9db3a7fe1d to your computer and use it in GitHub Desktop.
KEGG compound downloader
import requests
compounds = requests.get('http://rest.kegg.jp/list/compound')
for line in compounds.content.split('\n'):
    cpdid = line.split('\t')[0]
    compound = requests.get('http://rest.kegg.jp/get/' + cpdid)
    f = open(cpdid[4:], 'w')
    f.write(compound.content)
    f.close()
print "finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment