欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

requests re 简单使用

程序员文章站 2022-07-10 08:22:31
...
import requests
import re
url = 'https://www.dianping.com/shop/12600401'

header = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'
}
html = requests.get(url=url,headers=header).text
import pdb;pdb.set_trace()
shopName = re.findall(r'(?<=shopName: ").+(?=", address)',html) # 以列表类型返回全部能匹配的子串
print(shopName)
相关标签: re