MCPcopy Create free account
hub / github.com/Boris-code/feapder / get_info

Function get_info

feapder/utils/tools.py:652–682  ·  view source on GitHub ↗
(html, regexs, allow_repeat=True, fetch_one=False, split=None)

Source from the content-addressed store, hash-verified

650
651# @log_function_time
652def get_info(html, regexs, allow_repeat=True, fetch_one=False, split=None):
653 regexs = isinstance(regexs, str) and [regexs] or regexs
654
655 infos = []
656 for regex in regexs:
657 if regex == "":
658 continue
659
660 if regex not in _regexs.keys():
661 _regexs[regex] = re.compile(regex, re.S)
662
663 if fetch_one:
664 infos = _regexs[regex].search(html)
665 if infos:
666 infos = infos.groups()
667 else:
668 continue
669 else:
670 infos = _regexs[regex].findall(str(html))
671
672 if len(infos) > 0:
673 # print(regex)
674 break
675
676 if fetch_one:
677 infos = infos if infos else ("",)
678 return infos if len(infos) > 1 else infos[0]
679 else:
680 infos = allow_repeat and infos or sorted(set(infos), key=infos.index)
681 infos = split.join(infos) if split else infos
682 return infos
683
684
685def table_json(table, save_one_blank=True):

Callers 8

get_urlsFunction · 0.85
is_have_chineseFunction · 0.85
is_have_englishFunction · 0.85
get_chinese_wordFunction · 0.85
get_english_wordsFunction · 0.85
get_jsonFunction · 0.85
format_dateFunction · 0.85
quick_to_jsonFunction · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected