-
Notifications
You must be signed in to change notification settings - Fork 2
/
Json_output.py
27 lines (21 loc) · 1004 Bytes
/
Json_output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import client
import pprint
import html_text
def result(key, url):
initiate_call = client.MercuryAPICall(private_api_key=key)
smart_article = initiate_call.parse_article(url)
json_output = smart_article.json()
return json_output
'''Can see the example output in json format by uncommenting the lines below'''
#a=result('zEbEqMY846voNjx8urJPNdDW99amKrRnjbLXkZz0', 'http://timesofindia.indiatimes.com/nri/other-news/uk-gets-its-first-female-sikh-mp-in-general-election/articleshow/59064564.cms')
#pprint.pprint(a)
'''Uncomment these 3 lines to get only th text of main content'''
# tree = html_text.parse_html(a['content'])
# text = html_text.extract_text(tree)
# print(text)
#Better way to print the result
if __name__=='__main__':
api_key = 'zEbEqMY846voNjx8urJPNdDW99amKrRnjbLXkZz0' #input('Enter the api key')
article_url = input("Enter the article's url")
response = result('zEbEqMY846voNjx8urJPNdDW99amKrRnjbLXkZz0', article_url)
pprint.pprint(response)