HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
dc_processor.custom_extractor.CustomExtractor Class Reference
Inheritance diagram for dc_processor.custom_extractor.CustomExtractor:
Collaboration diagram for dc_processor.custom_extractor.CustomExtractor:

Public Member Functions

def __init__ (self, config, templ=None, domain=None, processorProperties=None)
 
def extractTags (self, resource, reslut)
 
- Public Member Functions inherited from dc_processor.base_extractor.BaseExtractor
def __init__ (self, config, templ=None, domain=None, processorProperties=None)
 
def __str__ (self)
 
def __repr__ (self)
 
def loadScraperProperties (self, scraperPropFileName)
 
def isTagNotFilled (self, result, tagName)
 
def isTagValueNotEmpty (self, tagValue)
 
def tagValueElemValidate (self, tagValueElem, conditionElem)
 
def tagValueValidate (self, tagName, tagValue)
 
def addTag (self, result, tag_name, tag_value, xpath="", isDefaultTag=False, callAdjustment=True, tagType=None, allowNotFilled=False)
 
def calculateMetrics (self, response)
 
def rankReading (self, exctractorName)
 

Public Attributes

 name
 
- Public Attributes inherited from dc_processor.base_extractor.BaseExtractor
 config
 
 processorProperties
 
 name
 
 rank
 
 process_mode
 
 modules
 
 data
 
 db_dc_scraper_db
 
 DBConnector
 
 imgDelimiter
 
 tagsValidator
 

Additional Inherited Members

- Static Public Attributes inherited from dc_processor.base_extractor.BaseExtractor
 properties = None
 
dictionary tag
 
dictionary tagsMask
 

Detailed Description

Definition at line 27 of file custom_extractor.py.

Constructor & Destructor Documentation

◆ __init__()

def dc_processor.custom_extractor.CustomExtractor.__init__ (   self,
  config,
  templ = None,
  domain = None,
  processorProperties = None 
)

Definition at line 36 of file custom_extractor.py.

36  def __init__(self, config, templ=None, domain=None, processorProperties=None):
37  try:
38  BaseExtractor.__init__(self, config, templ, domain, processorProperties)
39  logger.debug("Properties: %s", varDump(self.properties))
40  self.name = "Custom extractor"
41  # set module rank from module's properties
42  self.rankReading(self.__class__.__name__)
43  self.data["extractor"] = self.name
44  except Exception as err:
45  ExceptionLog.handler(logger, err, "Custom extractor constructor error: possible /tmp not permitted to write", (),
46  {ExceptionLog.LEVEL_NAME_ERROR:ExceptionLog.LEVEL_VALUE_DEBUG})
47  raise
48 
49 
def varDump(obj, stringify=True, strTypeMaxLen=256, strTypeCutSuffix='...', stringifyType=1, ignoreErrors=False, objectsHash=None, depth=0, indent=2, ensure_ascii=False, maxDepth=10)
Definition: Utils.py:410
def __init__(self)
constructor
Definition: UIDGenerator.py:19
Here is the call graph for this function:

Member Function Documentation

◆ extractTags()

def dc_processor.custom_extractor.CustomExtractor.extractTags (   self,
  resource,
  reslut 
)

Definition at line 54 of file custom_extractor.py.

54  def extractTags(self, resource, reslut):
55  # support time execution limit
56  signal.signal(signal.SIGALRM, signal_handler)
57  if 'EXTRACTOR_CUSTOM_MAX_EXECUTION' in self.processorProperties:
58  t = int(self.processorProperties['EXTRACTOR_CUSTOM_MAX_EXECUTION'])
59  else:
60  t = CONSTS.TIME_EXECUTION_LIMIT
61  signal.alarm(t)
62  logger.debug("Max execution time signal handler set timeout as: %s", str(t))
63 
64  try:
65  if resource.raw_html is not None and isinstance(resource.raw_html, types.DictType):
66  for key in resource.raw_html:
67  localTagValue = resource.raw_html[key] if isinstance(resource.raw_html[key], types.ListType) else \
68  [str(resource.raw_html[key])]
69  self.addTag(result=reslut, tag_name=key, tag_value=localTagValue)
70  except IOError as err:
71  ExceptionLog.handler(logger, err, "Custom extractor file error. It may be unsupported encoding like jp", (), \
72  {ExceptionLog.LEVEL_NAME_ERROR:ExceptionLog.LEVEL_VALUE_DEBUG})
73  except Exception as err:
74  ExceptionLog.handler(logger, err, "Custom extractor error", (), \
75  {ExceptionLog.LEVEL_NAME_ERROR:ExceptionLog.LEVEL_VALUE_DEBUG})
76  return reslut
77 
Here is the call graph for this function:

Member Data Documentation

◆ name

dc_processor.custom_extractor.CustomExtractor.name

Definition at line 40 of file custom_extractor.py.


The documentation for this class was generated from the following file: