tszr

吴裕雄--天生自然python学习笔记:案例:用正则表达式查找邮件账号

抓取万水书苑“ ht甲://www.w sbookshow.com/ ”网站中的所有 E-mai l 账号。
import requests,re

regex = re.compile(\'[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+\')
url = \'http://www.wsbookshow.com/\'
html = requests.get(url)
emails = regex.findall(html.text)
for email in emails:
    print(email)

 

 

程序说明
导入 request 包和 re 包。 re 包就是正则表达式 Cregex ),通过
re . compile 方法创建正则表达式对象 regex .
抓取“http :/川ww. wsbookshow.com/ ”网站的源代码 。
在 html.text 中查找所有 E-mail 账号,然后进行显示。

 

发表于 2019-12-11 09:56  吴裕雄  阅读(169)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-12-04
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2021-12-23
  • 2022-02-07
  • 2022-01-24
  • 2022-12-23
猜你喜欢
  • 2021-12-15
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-01-14
  • 2021-12-04
相关资源
相似解决方案