Advertisement
hakegawa

Untitled

Aug 10th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import requests
  4.  
  5.  
  6. class CheckUrl(object):
  7. OLD_API_URLS = ['http://api.news.rambler.ru/newapi/fast/rambler/head/',
  8. 'http://api.news.rambler.ru/newapi/fast/rambler/ukraine/',
  9. 'http://api.news.rambler.ru/newapi/fast/rambler/moscow_city/',
  10. 'http://api.news.rambler.ru/newapi/fast/rambler/politics/',
  11. 'http://api.news.rambler.ru/newapi/fast/rambler/sport/',
  12. 'http://api.news.rambler.ru/newapi/fast/rambler/incidents/',
  13. 'http://api.news.rambler.ru/newapi/fast/rambler/auto/',
  14. 'http://api.news.rambler.ru/newapi/fast/rambler/scitech/',
  15. 'http://api.news.rambler.ru/newapi/fast/rambler/games/',
  16. 'http://api.news.rambler.ru/newapi/fast/rambler/business/',
  17. 'http://api.news.rambler.ru/newapi/fast/rambler/lifestyle/',
  18. 'http://api.news.rambler.ru/newapi/fast/rambler/health/',
  19. 'http://api.news.rambler.ru/newapi/fast/rambler/starlife/',
  20. 'http://api.news.rambler.ru/fast/topics/articles/clusters/']
  21.  
  22. NEW_API_URLS = ['http://coolstream.rambler.ru/top/clusters/comments',
  23. 'http://coolstream.rambler.ru/topics/tree/?project_id=1',
  24. 'http://coolstream.rambler.ru/topics/tree/?project_id=2',
  25. 'http://coolstream.rambler.ru/topics/tree/?project_id=3',
  26. 'http://coolstream.rambler.ru/topics/tree/?project_id=4',
  27. 'http://coolstream.rambler.ru/topics/tree/?project_id=5',
  28. 'http://coolstream.rambler.ru/topics/tree/?project_id=6',
  29. 'http://coolstream.rambler.ru/topics/tree/?project_id=7',
  30. 'http://coolstream.rambler.ru/topics/tree/?project_id=8',
  31. 'http://coolstream.rambler.ru/top/clusters/comments',
  32. 'http://coolstream.rambler.ru/clusters/top/?period=day',
  33. 'http://coolstream.rambler.ru/clusters/top/?period=week',
  34. 'http://coolstream.rambler.ru/clusters/top/?period=month',
  35. 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=1',
  36. 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=2',
  37. 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=3',
  38. 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=4',
  39. 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=5',
  40. 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=6',
  41. 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=7',
  42. 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=8',
  43. 'http://clstream.rambler.ru/v1/clusters/autotag/?project_id=1&alias=mvd&type=Organization:Name',
  44. 'http://clstream.rambler.ru/v1/clusters/autotag/'
  45. '?project_id=1&alias=interfaks&type=Organization:MassMedia',
  46. 'http://clstream.rambler.ru/v1/clusters/autotag/?project_id=1&alias=peydzh-larri&type=Person:Name',
  47. 'http://coolstream.rambler.ru/v1/clusters/autotag/all/?alias=kino&relation=all&type=Category',
  48. 'http://coolstream.rambler.ru/v1/clusters/tag/?project_id=1&alias=mom',
  49. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=1',
  50. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=2',
  51. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=3',
  52. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=4',
  53. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=5',
  54. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=6',
  55. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=7',
  56. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=8']
  57.  
  58. def check_url(self):
  59. failures = None
  60. urls = self.OLD_API_URLS + self.NEW_API_URLS
  61. for url in urls:
  62. r = requests.get(url, timeout=5)
  63. sc = r.status_code
  64. failures = []
  65. try:
  66. assert sc == 200
  67. except:
  68. failures.append([url, sc])
  69.  
  70. if failures:
  71. for failure in failures:
  72. url = failure[0]
  73. sc = failure[1]
  74.  
  75. print('Url: {} return status code: {}'.format(url, sc))
  76.  
  77.  
  78. if __name__ == '__main__':
  79. c = CheckUrl()
  80. c.check_url()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement