Advertisement
hakegawa

Untitled

Aug 11th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import requests
  4.  
  5.  
  6. class CheckUrl(object):
  7. def old_api_urls(self):
  8. urls = ['http://api.news.rambler.ru/newapi/fast/rambler/head/',
  9. 'http://api.news.rambler.ru/newapi/fast/rambler/ukraine/',
  10. 'http://api.news.rambler.ru/newapi/fast/rambler/moscow_city/',
  11. 'http://api.news.rambler.ru/newapi/fast/rambler/politics/',
  12. 'http://api.news.rambler.ru/newapi/fast/rambler/sport/',
  13. 'http://api.news.rambler.ru/newapi/fast/rambler/incidents/',
  14. 'http://api.news.rambler.ru/newapi/fast/rambler/auto/',
  15. 'http://api.news.rambler.ru/newapi/fast/rambler/scitech/',
  16. 'http://api.news.rambler.ru/newapi/fast/rambler/games/',
  17. 'http://api.news.rambler.ru/newapi/fast/rambler/business/',
  18. 'http://api.news.rambler.ru/newapi/fast/rambler/lifestyle/',
  19. 'http://api.news.rambler.ru/newapi/fast/rambler/health/',
  20. 'http://api.news.rambler.ru/newapi/fast/rambler/starlife/',
  21. 'http://api.news.rambler.ru/fast/topics/articles/clusters/']
  22.  
  23. return urls
  24.  
  25. def new_api_urls(self):
  26. urls = [
  27. 'http://coolstream.rambler.ru/top/clusters/comments',
  28. 'http://coolstream.rambler.ru/clusters/top/?period=day',
  29. 'http://coolstream.rambler.ru/clusters/top/?period=week',
  30. 'http://coolstream.rambler.ru/clusters/top/?period=month',
  31. 'http://coolstream.rambler.ru/clusters/autotag/?project_id=1&alias=mvd&type=Organization:Name',
  32. 'http://coolstream.rambler.ru/v1/clusters/autotag/?project_id=1'
  33. '&alias=interfaks&type=Organization:MassMedia',
  34. 'http://coolstream.rambler.ru/v1/clusters/autotag/?project_id=1&alias=peydzh-larri&type=Person:Name',
  35. 'http://coolstream.rambler.ru/v1/clusters/autotag/all/?alias=kino&relation=all&type=Category',
  36. 'http://coolstream.rambler.ru/v1/clusters/tag/?project_id=1&alias=mom',
  37. 'http://coolstream.rambler.ru/clusters/info/?ids=37614220',
  38. 'http://coolstream.rambler.ru/v1/items/resource/popular/?oid=37529652&alias=politics',
  39. 'http://coolstream.rambler.ru/v1/clusters/topic/?id=42',
  40. 'http://coolstream.rambler.ru/regions/tree/',
  41. 'http://coolstream.rambler.ru/v1/stories/info/?ids=200',
  42. 'http://coolstream.rambler.ru/v1/clusters/story?story_id=200',
  43. 'http://coolstream.rambler.ru/v1/clusters/region/?id=65',
  44. 'http://coolstream.rambler.ru/topic/articles/?alias=politics&ctype=3',
  45. 'http://coolstream.rambler.ru/teaser/vk/?region=200'
  46. ]
  47.  
  48. return urls
  49.  
  50. def new_api_urls_with_project_id(self):
  51. urls = ['http://coolstream.rambler.ru/topics/tree/?',
  52. 'http://coolstream.rambler.ru/v1/clusters/latest/?',
  53. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?alias=video&',
  54. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?alias=photo&',
  55. 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?alias=articles&',
  56. 'http://coolstream.rambler.ru/breaking/current?',
  57. 'http://coolstream.rambler.ru/v1/clusters/?date_from=2017-08-01&date_to=2017-07-01&']
  58.  
  59. new_urls = []
  60.  
  61. for i in range(1, 9):
  62. new_url = [url + 'project_id=' + str(i) for url in urls]
  63.  
  64. new_urls.append(new_url)
  65.  
  66. urls = sum(new_urls, [])
  67.  
  68. return urls
  69.  
  70. def check_url(self):
  71. old_api_urls = self.old_api_urls()
  72. new_api_urls = self.new_api_urls() + self.new_api_urls_with_project_id()
  73. urls = old_api_urls + new_api_urls
  74. for url in urls:
  75. r = requests.get(url)
  76. sc = r.status_code
  77. try:
  78. assert sc == 200
  79. except AssertionError:
  80. print('Url: {} return status code: {}'.format(url, sc))
  81. except Exception, e:
  82. print('Failed to check due error: ' + str(e))
  83.  
  84. if __name__ == '__main__':
  85. c = CheckUrl()
  86. c.check_url()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement