Пример #1
0
def handle_thread_exception(func, _dict):
    try:
        func(_dict)
    except Exception, e:
        msg = 'ERROR INFO in {func}: {e}'.format(func=func, e=e)
        logger.error(
            tools.format_error_msg(inspect.stack()[1][1],
                                   inspect.stack()[1][3], msg))
Пример #2
0
 def get_data_by_re(self, html_page_source, pattern, flags=re.DOTALL):
     try:
         data = re.findall(pattern, html_page_source, flags=flags)
     except Exception, e:
         msg = 'Error msg: %s in [get_data_by_re]' % e
         self.logger.error(
             format_error_msg(inspect.stack()[1][1],
                              inspect.stack()[1][3], msg))
Пример #3
0
 def get_data_by_json(self, html_page_source):
     try:
         data = json.loads(html_page_source)
     except Exception, e:
         msg = 'Error msg: %s in [get_data_by_json]' % e
         self.logger.error(
             format_error_msg(inspect.stack()[1][1],
                              inspect.stack()[1][3], msg))
Пример #4
0
 def get_data_by_xpath(self, html_page_source, urls_xpath):
     try:
         self.doc = H.document_fromstring(html_page_source)
     except Exception, e:
         msg = 'Error msg: %s in [get_data_by_xpath]' % e
         self.logger.error(
             format_error_msg(inspect.stack()[1][1],
                              inspect.stack()[1][3], msg))