Created
May 5, 2016 18:34
-
-
Save devStepsize/e6ed0a0b3a146e048e09e1bf4a6da70e to your computer and use it in GitHub Desktop.
Get the topics of a webpage using the AlchemyAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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