import re
from selenium import webdriver
driver=webdriver.Firefox()
driver.get(“http://home.baidu.com/home/index/contact_us“)
doc=driver.page_source #查看页面的源代码
emails=re.findall(r’[\w]+@[\w.-]+’,doc) #正则表达式匹配邮箱(字符串前加r表示原生字符串,\w表示匹配字母数字及下划线,findall返回的是一个匹配字符串的列表 )
循环打印匹配的邮箱
for email in emails:
print(email)