python-正则表达试-实践1

匹配html标签中的任意标签内数据

  1. 匹配所有包含'oo'的单词

    python 复制代码
    import re
    text = "JGood is a handsome boy, he is cool, clever, and so on..."
    re.findall(r'\w*oo\w*', text) 
  2. 匹配 html中title里面的内容

    原文:

python 复制代码
import re
file = r'./202304.html'
f = open(file,'r',encoding='utf-8')
origin_content = f.read()
#r'<title>(.*)</title>'  效果一样
result = re.findall(r'<title>(.*?)</title>',origin_content)
print(result)
f.close()

打印内容:

相关推荐
我材不敲代码3 小时前
Python实现打包贪吃蛇游戏
开发语言·python·游戏
0思必得05 小时前
[Web自动化] Selenium处理动态网页
前端·爬虫·python·selenium·自动化
韩立学长5 小时前
【开题答辩实录分享】以《基于Python的大学超市仓储信息管理系统的设计与实现》为例进行选题答辩实录分享
开发语言·python
qq_192779875 小时前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python
u0109272715 小时前
使用Plotly创建交互式图表
jvm·数据库·python
爱学习的阿磊5 小时前
Python GUI开发:Tkinter入门教程
jvm·数据库·python
Imm7776 小时前
中国知名的车膜品牌推荐几家
人工智能·python
tudficdew6 小时前
实战:用Python分析某电商销售数据
jvm·数据库·python
sjjhd6527 小时前
Python日志记录(Logging)最佳实践
jvm·数据库·python
2301_821369617 小时前
用Python生成艺术:分形与算法绘图
jvm·数据库·python