当前位置:网站首页>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"))边栏推荐
- 层次分析法
- Multithreading tool class completabilefuture
- [C language] flexible array
- Daily question - force deduction - multiply the found value by 2
- IDEA 集成 码云
- Qt QFrame详解
- 'only_ full_ group_ The influence of by'sql mode on group by and its treatment
- 力扣每日一题-第30天-1281.整数的各位积和之差
- JDBC | Chapter 6: simple use of database connection pool
- Vite quick start
猜你喜欢

How to fix Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorli

mongostat性能分析
![[when OSPF introduces direct connection routes, it makes a summary by using static black hole routes]](/img/a8/f77cc5e43e1885171e73f8ab543ee4.png)
[when OSPF introduces direct connection routes, it makes a summary by using static black hole routes]

Presto-Trial

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

UVM authentication platform

json tobean

jetson tx2

力扣今日题-324. 摆动排序 II

Chapter V online logic analyzer signaltap
随机推荐
UVM authentication platform
Configuring MySQL 5.7 and 8 under CentOS
NoSQL数据库之Redis(四):Redis的发布和订阅
融入STEAM教育的劳动技能课程
Service grid ASM year end summary: how do end users use the service grid?
VerilogA——动态比较器
How to fix Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorli
Error: GPG check FAILED Once install MySQL
Error: GPG check FAILED Once install MySQL
[MySQL technology topic] technical analysis and guide for analyzing the high availability architecture of MySQL
数据库-同义词
Qt QFileInfo简介
Message queue batch processing refund order through queue
百度小程序自动提交搜索
Qt QFrame详解
Class differences of QT processing image data (qpixmap, qimage, qpicture)
'only_ full_ group_ The influence of by'sql mode on group by and its treatment
Daily question - force deduction - multiply the found value by 2
As a qualified network worker, you must master DHCP snooping knowledge!
How does schedulerx help users solve distributed task scheduling problems?