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爬虫零基础入门【第七章:动态页面入门(Playwright)·第1节】Playwright 第一次:打开页面、等待元素、拿到渲染后 HTML!
爬虫·python·爬虫实战·动态页面·playwright·python爬虫工程化实战·零基础python爬虫教学
一个无名的炼丹师3 小时前
DeepSeek+LangGraph构建企业级多模态RAG:从PDF复杂解析到Agentic智能检索全流程实战
python·pdf·大模型·多模态·rag
历程里程碑3 小时前
哈希3 : 最长连续序列
java·数据结构·c++·python·算法·leetcode·tornado
火云洞红孩儿3 小时前
2026年,用PyMe可视化编程重塑Python学习
开发语言·python·学习
2401_841495643 小时前
【LeetCode刷题】两两交换链表中的节点
数据结构·python·算法·leetcode·链表·指针·迭代法
幻云20103 小时前
Next.js 之道:从入门到精通
前端·javascript·vue.js·人工智能·python
SunnyDays10113 小时前
使用 Python 自动查找并高亮 Word 文档中的文本
经验分享·python·高亮word文字·查找word文档中的文字
深蓝电商API3 小时前
Selenium处理弹窗、警报和验证码识别
爬虫·python·selenium
深蓝电商API3 小时前
Selenium模拟滚动加载无限下拉页面
爬虫·python·selenium
小王子10243 小时前
Redis Queue 安装与使用
redis·python·任务队列·rq·redis queue