Changeset 13 in feed2telegram
- Timestamp:
- 10/09/18 19:44:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/feed2telegram.py
r12 r13 81 81 return time.mktime(timetuple) 82 82 83 class Cloudflare: 84 @staticmethod 85 def check(response): 86 return response.status_code == 503 and 'DDoS protection by Cloudflare' in response.content 87 88 @staticmethod 89 def get(*args, **kwargs): 90 import cfscrape 91 return cfscrape.create_scraper().get(*args, **kwargs) 92 83 93 class Feed: 84 94 def __init__(self, url): … … 122 132 try: 123 133 resp = requests.get(self.url, timeout=10.0) 134 if Cloudflare.check(resp): 135 resp = Cloudflare.get(self.url, timeout=10.0) 124 136 except requests.ReadTimeout as e: 125 137 raise
Note:
See TracChangeset
for help on using the changeset viewer.