Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import requests
- class CheckUrl(object):
- OLD_API_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/']
- NEW_API_URLS = ['http://coolstream.rambler.ru/top/clusters/comments',
- 'http://coolstream.rambler.ru/topics/tree/?project_id=1',
- 'http://coolstream.rambler.ru/topics/tree/?project_id=2',
- 'http://coolstream.rambler.ru/topics/tree/?project_id=3',
- 'http://coolstream.rambler.ru/topics/tree/?project_id=4',
- 'http://coolstream.rambler.ru/topics/tree/?project_id=5',
- 'http://coolstream.rambler.ru/topics/tree/?project_id=6',
- 'http://coolstream.rambler.ru/topics/tree/?project_id=7',
- 'http://coolstream.rambler.ru/topics/tree/?project_id=8',
- '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/v1/clusters/latest/?project_id=1',
- 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=2',
- 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=3',
- 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=4',
- 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=5',
- 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=6',
- 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=7',
- 'http://coolstream.rambler.ru/v1/clusters/latest/?project_id=8',
- 'http://clstream.rambler.ru/v1/clusters/autotag/?project_id=1&alias=mvd&type=Organization:Name',
- 'http://clstream.rambler.ru/v1/clusters/autotag/'
- '?project_id=1&alias=interfaks&type=Organization:MassMedia',
- 'http://clstream.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/top/clusters/projects/filtered/?top_type=3&project_id=1',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=2',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=3',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=4',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=5',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=6',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=7',
- 'http://coolstream.rambler.ru/top/clusters/projects/filtered/?top_type=3&project_id=8']
- def check_url(self):
- failures = None
- urls = self.OLD_API_URLS + self.NEW_API_URLS
- for url in urls:
- r = requests.get(url, timeout=5)
- sc = r.status_code
- failures = []
- try:
- assert sc == 200
- except:
- failures.append([url, sc])
- if failures:
- for failure in failures:
- url = failure[0]
- sc = failure[1]
- print('Url: {} return status code: {}'.format(url, sc))
- if __name__ == '__main__':
- c = CheckUrl()
- c.check_url()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement