Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devStepsize/e6ed0a0b3a146e048e09e1bf4a6da70e to your computer and use it in GitHub Desktop.
Save devStepsize/e6ed0a0b3a146e048e09e1bf4a6da70e to your computer and use it in GitHub Desktop.
Get the topics of a webpage using the AlchemyAPI
import requests
endpoint = "http://gateway-a.watsonplatform.net/calls/url/URLGetRankedTaxonomy"
parameters = {
'apikey': API_KEY,
'outputMode': 'json',
'url': 'https://blog.vellumatlanta.com/2016/05/04/apple-stole-my-music-no-seriously/'
}
r = requests.get(endpoint, params=parameters)
if r.status_code == 200:
resp = r.json()
topics = [(t['label'], t['score']) for t in resp.get('taxonomy')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment