Python 提取網頁中的電子郵箱

2021-07-26 12:45:52 字數 794 閱讀 7448

我們使用其它程式語言處理在文字中查詢「類似」的內容時,往往使用正規表示式,python在網頁上找出所有「類似」的內容,也是要用正規表示式。

在python中,使用正規表示式的模組是「re",正規表示式模組"re"指定乙個與之匹配的字元集合,本模組所提供的函式,將可以用來檢查所給的字串是否與指定的正規表示式匹配。」re"模組的findall()函式可以找出如電子郵箱、**號碼、外部連線、檔案型別等形式。

import requests, re

#regex = r"([a-za-z0-9_.+-]+@[a-za-z0-9-]+\.[a-za-z0-9-.]+)"

#這個正規表示式過濾掉了qq郵箱

regex = r"([a-za-z0-9_.+-]+@[a-pr-za-prz0-9-]+\.[a-za-z0-9-.]+)"

#基於隱私,使用了「************xx」

提取網頁中的超連結

using system using system.xml using system.text using system.net using system.io using system.collections using system.text.regularexpressions console...

提取網頁中的超連結

using system using system.xml using system.text using system.net using system.io using system.collections using system.text.regularexpressions console...

提取網頁中的超連結

using system using system.xml using system.text using system.net using system.io using system.collections using system.text.regularexpressions console...