Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import requests
- class CheckUrl(object):
- def old_api_urls(self):
- urls = ['http://api.news.rambler.ru/newapi/fast/rambler/head/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/ukraine/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/moscow_city/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/politics/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/sport/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/incidents/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/auto/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/scitech/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/games/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/business/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/lifestyle/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/health/',
- 'http://api.news.rambler.ru/newapi/fast/rambler/starlife/',
- 'http://api.news.rambler.ru/fast/topics/articles/clusters/']
- return urls
- def new_api_urls(self):
- urls = [
- 'http://coolstream.rambler.ru/top/clusters/comments',
- 'http://coolstream.rambler.ru/clusters/top/?period=day',
- 'http://coolstream.rambler.ru/clusters/top/?period=week',
- 'http://coolstream.rambler.ru/clusters/top/?period=month',
- 'http://coolstream.rambler.ru/clusters/autotag/?project_id=1&alias=mvd&type=Organization:Name',
- 'http://coolstream.rambler.ru/v1/clusters/autotag/?project_id=1'
- '&alias=interfaks&type=Organization:MassMedia',
- 'http://coolstream.rambler.ru/v1/clusters/autotag/?project_id=1&alias=peydzh-larri&type=Person:Name',
- 'http://coolstream.rambler.ru/v1/clusters/autotag/all/?alias=kino&relation=all&type=Category',
- 'http://coolstream.rambler.ru/v1/clusters/tag/?project_id=1&alias=mom',
- 'http://coolstream.rambler.ru/clusters/info/?ids=37614220',
- 'http://coolstream.rambler.ru/v1/items/resource/popular/?oid=37529652&alias=politics',
- 'http://coolstream.rambler.ru/v1/clusters/topic/?id=42',
- 'http://coolstream.rambler.ru/regions/tree/',
- 'http://coolstream.rambler.ru/v1/stories/info/?ids=200',
- 'http://coolstream.rambler.ru/v1/clusters/story?story_id=200',
- 'http://coolstream.rambler.ru/v1/clusters/region/?id=65',
- 'http://coolstream.rambler.ru/topic/articles/?alias=politics&ctype=3',
- 'http://coolstream.rambler.ru/teaser/vk/?region=200'
- ]
- return urls
- def new_api_urls_with_project_id(self):
- urls = ['http://coolstream.rambler.ru/topics/tree/?',
- 'http://coolstream.rambler.ru/v1/clusters/latest/?',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?alias=video&',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?alias=photo&',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?alias=articles&',
- 'http://coolstream.rambler.ru/breaking/current?',
- 'http://coolstream.rambler.ru/v1/clusters/?date_from=2017-08-01&date_to=2017-07-01&']
- new_urls = []
- for i in range(1, 9):
- new_url = [url + 'project_id=' + str(i) for url in urls]
- new_urls.append(new_url)
- urls = sum(new_urls, [])
- return urls
- def check_url(self):
- old_api_urls = self.old_api_urls()
- new_api_urls = self.new_api_urls() + self.new_api_urls_with_project_id()
- urls = old_api_urls + new_api_urls
- for url in urls:
- r = requests.get(url)
- sc = r.status_code
- try:
- assert sc == 200
- except AssertionError:
- print('Url: {} return status code: {}'.format(url, sc))
- except Exception, e:
- print('Failed to check due error: ' + str(e))
- if __name__ == '__main__':
- c = CheckUrl()
- c.check_url()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement