python抓取电话号码_Python爬虫实践 —— 5.便民生活网电话号码爬取

importreimportrequests

headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0"}

reponse= requests.get("http://changyongdianhuahaoma.51240.com/",headers=headers).text

pat1= re.compile(r‘

(.*?)[\s\S]*?‘)

pat2= re.compile(r‘

[\s\S]*?(.*?)‘)

data1=pat1.findall(reponse)

data2=pat2.findall(reponse)print(data1)print(data2)

resultlist=[]for i inrange(0, len(data1)):

resultlist.append(data1[i]+data2[i])print(resultlist)

你可能感兴趣的:(python抓取电话号码)