Mercurial > hg > index.fcgi > www > www-1
comparison myrss/myrss_app.py @ 91:6a45e46f0c05
myw: use new redirect_app
author | paulo |
---|---|
date | Thu, 06 Apr 2017 22:42:03 -0700 |
parents | 51f0da3da721 |
children | 8214951cb8e7 |
comparison
equal
deleted
inserted
replaced
9:49cdc4dc0890 | 10:9c2dd6337045 |
---|---|
159 | 159 |
160 | 160 |
161 def _fetch_url(url): | 161 def _fetch_url(url): |
162 try: | 162 try: |
163 logging.info("processing %s" % url) | 163 logging.info("processing %s" % url) |
164 feed = urllib2.urlopen(urllib2.Request(url, headers={"User-Agent": "Mozilla/5.0"}), timeout=URLOPEN_TIMEOUT) | 164 feed = urllib2.urlopen(urllib2.Request(url, headers={"User-Agent": "Mozilla/5.0 Browser"}), timeout=URLOPEN_TIMEOUT) |
165 except urllib2.HTTPError as e: | 165 except urllib2.HTTPError as e: |
166 logging.info("(%s) %s" % (url, e)) | 166 logging.info("(%s) %s" % (url, e)) |
167 return None | 167 return None |
168 | 168 |
169 return feed | 169 return feed |
207 try: | 207 try: |
208 feed = _fetch_url(url) | 208 feed = _fetch_url(url) |
209 if feed is not None: | 209 if feed is not None: |
210 docfeed = _process_feed(feed) | 210 docfeed = _process_feed(feed) |
211 except Exception as e: | 211 except Exception as e: |
212 logging.info("(%s) exception: %s" % (url, e)) | 212 logging.info("(%s) exception: (%s) %s" % (url, type(e), e)) |
213 self._output_queue.put((idx, docfeed)) | 213 self._output_queue.put((idx, docfeed)) |
214 | 214 |
215 | 215 |
216 def main(input_queue, output_queue, lock): | 216 def main(input_queue, output_queue, lock): |
217 ret = '' | 217 ret = '' |