Advertisement
Guest User

Untitled

a guest
May 24th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import requests
  2. import json
  3. import unicodedata
  4. from datetime import datetime
  5.  
  6. api_username = "7dc956e915c66d7fa4e4825316ec470f"
  7. api_password = "88ce45ae346a06b30f073e788be6dfc9"
  8. request_url = "https://api.intrinio.com/news?identifier=GOOGL&page_size=1"
  9. response = requests.get(request_url, auth=(api_username, api_password))
  10. # Report error
  11. if(response.status_code == 401):
  12. print("Unauthorized! Check your username and password.")
  13. exit()
  14. data = response.json()['data']
  15. print(data)
  16. for row in data:
  17. titleUni = str(unicodedata.normalize('NFKD', row['title']).encode('ascii', 'ignore'))
  18. title = str(titleUni)
  19. titleList = (title.strip()).split(' ')
  20. summaryUni = str(unicodedata.normalize('NFKD', row['summary']).encode('ascii', 'ignore'))
  21. summary = str(summaryUni)
  22. summaryList = summary.split(" ")
  23. publication_dateUni = str(unicodedata.normalize('NFKD', row['publication_date']).encode('ascii','ignore'))
  24. publication_date = str(publication_dateUni) # '2017-05-20 02:11:12 +0000'
  25. hasNewsToday = False
  26. pubDateList = publication_date.split()
  27. pubDate = pubDateList[0] # '2017-05-20'
  28. pubTime = pubDateList[1] # '02:11:12'
  29. print(publication_date, '::', title, '::', summary)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement