(page_html, pattern_str, pattern_ignore_case=re.I)
| 44 | |
| 45 | # 从页面中提取需要的部分(通常是链接也可以通过正则表达式进行指定) |
| 46 | def get_matched_parts(page_html, pattern_str, pattern_ignore_case=re.I): |
| 47 | pattern_regex = re.compile(pattern_str, pattern_ignore_case) |
| 48 | return pattern_regex.findall(page_html) if page_html else [] |
| 49 | |
| 50 | |
| 51 | # 开始执行爬虫程序 |