当前位置:网站首页>Crawler data analysis (introduction 2-re analysis)
Crawler data analysis (introduction 2-re analysis)
2022-06-29 07:04:00 【Low key $(life)】
re analysis
Regular test site Online regular expression testing




Code example
import re
# #findall
# lst = re.findall(r"\d+", " My phone number is 10086, My girlfriend's phone number is 10010")
# print(lst)
# #finditer
# it=re.finditer(r"\d+"," My phone number is 10086, My girlfriend's phone number is 10010")
# for i in it:
# print(i)
# print(i.group())
# #search Looking for the first .group() Get data
# s=re.search(r"\d+"," My phone number is 10086, My girlfriend's phone number is 10010")
# print(s.group())
#match Match from the beginning
# s=re.match(r"\d+","10086, My girlfriend's phone number is 10010")
# print(s.group())
# # Preload regular expressions
# obj=re.compile(r"\d+")
# ret=obj.finditer(" My phone number is 10086, My girlfriend's phone number is 10010")
# for it in ret:
# print(it.group())
#
# ret2=obj.findall("hhh Hahaha, East China and Wuhan 1000000000000000")
# print(ret2)
s = """
<div class='jay'><span id='1'> China Unicom </span></div>
<div class='ja'><span id='2'> China Mobile </span></div>
<div class='jy'><span id='3'> China Telecom </span></div>
<div class='jpl'><span id='4'> an old China hand </span></div>
<div class='jal'><span id='5'> China Federation </span></div>
"""
#(?P< Group name > Regular ) Further information can be extracted from the regular content alone
obj=re.compile(r"<div class='.*?'><span id='(?P<id>\d+)'>(?P<wahaha>.*?)</span></div>",re.S)#re.S Give Way . Can match newline
ret=obj.finditer(s)
for it in ret:
print(it.group("id"))
print(it.group("wahaha"))边栏推荐
- Go basic data type conversion
- json tobean
- json tobean
- List集合实现分页
- Li Kou daily question - day 30 -1281 Difference of sum of bit product of integer
- Chapter IV introduction to FPGA development platform
- 施工企业选择智慧工地的有效方法
- package.json的所有配置项及其用法,你都熟悉么
- The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
- Message queue avoiding repeated refund by idempotent design and atomic lock
猜你喜欢

QT program packaging and publishing windeployqt tool

消息队列之通过队列批处理退款订单

jetson tx2

The annual technology inventory of cloud primitives was released, and it was the right time to ride the wind and waves

Redistemplate handles hash integer type problem resolution

Creating a new generation of production and service tools with robot education

Share 10 interview questions related to JS promise

QT qframe details

Qt 串口编程

Suggestions on digital transformation of large chemical enterprises
随机推荐
Li Kou daily question - day 30 -1281 Difference of sum of bit product of integer
Draw multiple ROC curves on a graph
NoSQL数据库之Redis(二):Redis配置文件介绍
Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- length and angle measurement function
Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- path width style function
Baidu applet automatically submits search
Qt 容器类
UVM authentication platform
[c language] [sword finger offer article] - print linked list from end to end
力扣每日一题-第30天-1523.位1的个数
融入STEAM教育的劳动技能课程
Small program large screen adaptation Guide
IDEA 集成 码云
How to fix Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorli
Some thoughts on port forwarding program
WDCP accesses all paths that do not exist and jumps to the home page without returning 404
Draw smooth curves - methods needed - drawing smooth curves - methods needed
VerilogA——动态比较器
Aging design guide for applets
Effective methods for construction enterprises to select smart construction sites