'''
A basic implementation of calling Alchemy API using python.
I have used request library but you can use urllib too
'''
import requests
import json
from BeautifulSoup import BeautifulSoup
sentiments = 'any positive negative neutral'
sentiments = sentiments.split()
types = 'free text person city company organization'
types = types.split()
api_key = "cdad43590134920e8f031aeca32b196f1296d637"
def news_api(text, type, sentiment_type,):
url="https://access.alchemyapi.com/calls/data/GetNews?apikey="+api_key+"\
&return=enriched.url.title&start=1431561600&end=1432249200&q.enriched.url.enrichedTitle.entities.entity=|\
text="+text+",type="+type+"|&q.enriched.url.enrichedTitle.docSentiment.type="+sentiment_type+"&q.enriched.url.enrichedTitle.taxonomy.taxonomy_.label=technology%20and%20computing&count=25&outputMode=json"
print url
s = requests.get(url).text;
print s
news_api("IBM Mainframes", types[0], "positive")
'''
taxonomy label:
any
art and entertainment
automotive and vehicles
business and industrial
careers
education
family and parenting
finance
food and drink
health and fitness
hobbies and interests
home and garden
law, govt and politics
news
pets
real estate
religion and spirituality
science
shopping
society
sports
style and fashion
technology and computing
travel
'''