正则表达式提取红牛公司数据
发布时间
阅读量:
阅读量
正则表达式的应用依然充满趣味性,可用于从红牛官方网站中提取各分公司的相关信息。
import requests
import re
import pandas as pd
response = requests.get(url="http://www.redbull.com.cn/about/branch")
company = re.findall('<h2>(.*?)</h2>', response.text)
add = re.findall("<p class=\'mapIco\'>(.*?)</p>", response.text)
mail = re.findall("<p class=\'mailIco\'>(.*?)</p>",response.text)
tel = re.findall("<p class=\'telIco\'>(.*?)</p>",response.text)
df =pd.DataFrame({'company':company,'add':add,'mail':mail,'tel':tel})
df.to_excel(excel_writer="data/redbull_re.xlsx",index=None)
df.head()
全部评论 (0)
还没有任何评论哟~
