Skip to content

Instantly share code, notes, and snippets.

@mtholder
Created May 23, 2022 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtholder/615f1f77af9b7db8f0f9220fa514ab07 to your computer and use it in GitHub Desktop.
Save mtholder/615f1f77af9b7db8f0f9220fa514ab07 to your computer and use it in GitHub Desktop.
grab a newick tree from timetree for your personal research and teaching use if you have the study id (passed in as a command line arg)
#!/usr/bin/env python
import requests
import sys
durl = 'http://www.timetree.org/ajax/newick/publishedtree/download'
for i in sys.argv[1:]:
url = 'http://www.timetree.org/api/widget/citation_data/{i}'.format(i=i)
s = requests.Session()
r = s.get(url)
nr = s.post(durl, data={'export': 'newick', 'rank': 'na'})
nr.raise_for_status()
print(nr.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment