#导入请求、报错模块&正则表达式类库;
import urllib
import requests
import re
key_name = "python"
#定义函数,将爬到的每一页的商品url写入到文件;
url = "https://search.jd.com/Search?keyword=" + key_name +"&enc=utf-8"
print(url)
# 拿到每页源码;
// headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"}
data1 = requests.get(url,headers =headers).content.decode()
#定义匹配规则';
pat = 'sr