代码拉取完成,页面将自动刷新
import requests
import re
import json
url = 'https://module-jshop.jd.com/module/getModuleHtml.html?pageNo=1'
heads = {
"cookie": "__jdu=1644500971679414115849; shshshfpb=wAMJB-qISSdFo6_48nOfJBg; shshshfpa=29b39fba-495b-874e-5039-2cb8007a5aa9-1645714695; unpl=JF8EAMhnNSttC0tdBhwKGxoQG1lQW1kLSh9UbDRVUg8LSFFVSVBORUJ7XlVdXxRKFR9sbhRUWlNOUw4YAisSEXteXVdZDEsWC2tXVgQFDQ8VXURJQlZAFDNVCV9dSRZRZjJWBFtdT1xWSAYYRRMfDlAKDlhCR1FpMjVkXlh7VAQrAhwXFU9cVVZbCEwRC2pnAFRdXEJRDSsDKxUge21UXV4LTRczblcEZB8MF1IHHAAaG11LWlFbWQlKHwVvYANcWFhOVAUfCx4aIEptVw; __jdv=76161171|baidu-pinzhuan|t_288551095_baidupinzhuan|cpc|0f3d30c8dba7459bb52f2eb5eba8ac7d_0_b18269191a5545209f2ba7cb24accdfc|1679993181882; areaId=20; ipLoc-djd=20-1726-0-0; PCSYCityID=CN_450000_450300_0; mt_xid=V2_52007VwMVV1hcU1sXTxlbA28GElddWFZTGkEpCFBuURVRXA9OChscH0AAYARHTlVRUQ8DSklVUGMDGlMKXFZaL0oYXwd7AhBOXlFDWhhCHFsOZAAiUm1YYloeTBhVDWMAElReaFZeHEs%3D; shshshfpx=29b39fba-495b-874e-5039-2cb8007a5aa9-1645714695; __jda=122270672.1644500971679414115849.1644500971.1677402613.1679993182.25; __jdc=122270672; joyytokem=babel_2hnSsahPPZyb169esgZkQFr157EMMDFHUGhHSTk5MQ==.dmZffnB+Y1l/enVlWjkQNTMPIQ8TOTIpN3Z8Xmt4a2EWdTd2Lh8GBA0SRTYAFAMMASZxD1x/Jwg2IgUuOS4=.0751a2e5; shshshfp=a5d4581154b44da9ce98efa7d091aa8b; joyya=1679993183.1679993184.18.0djif07; CA1AN5BV0CA8DS2EPC=44199d4a6c1f697bd553ed8e8623237c; PCA9D23F7A4B3CSS=9828998353d8df970d6ac37e080f9ffe; jsavif=0; __jdb=122270672.11.1644500971679414115849|25.1679993182; 3AB9D23F7A4B3CSS=jdd03C5FDAUWGBNEB3BPAMOZ2WFKH7HZASKEIWHYG4HOFQTEVNN4DUDXGBOA4U5FYCLLNMAC24GSAXY5ZVI7LM6WQGZ7I7QAAAAMHE5VRAGQAAAAADLQW4OVU2O47EUX; _gia_d=1; JSESSIONID=81D8D7AB2F4FBA87640C4B70F8AC598D.s1; 3AB9D23F7A4B3C9B=C5FDAUWGBNEB3BPAMOZ2WFKH7HZASKEIWHYG4HOFQTEVNN4DUDXGBOA4U5FYCLLNMAC24GSAXY5ZVI7LM6WQGZ7I7Q; shshshsID=f10352d4e068ce389732be7dc8ab6cfe_12_1679993616008",
"referer": "https://mall.jd.com/",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.42"
}
date ={
"pagePrototypeId": 8,
"orderBy": 1,
"pageSize": 24,
"categoryId": 0,
"direction": 1,
"pageInstanceId":7945195,
"moduleInstanceId":333531628,
"prototypeId":68,
"templateId": 1201522,
"appId": 204061,
"layoutInstanceId": 333531628,
"origin": 0,
"shopId": 58463,
"venderId": 62710,
"callback": "jshop_module_render_callback",
"_": 1679993616335
}
datemax = requests.get(url, headers=heads, params=date)
cli = re.compile(r'{"result":true.*}', re.S)
shopingbox =re.compile(r'<divclass=\\"jGoodsInfo\\">.*?立即购买</a></div>')
njoson = cli.findall(datemax.text)[0]
str = ''.join(njoson.split())
jsoncontent = re.sub(r"\\r", "", str)
jsoncontent = re.sub(r"\\n", "", jsoncontent)
jsoncontent = re.sub(r"\\t", "", jsoncontent)
datejson =json.loads(str)
datelist = shopingbox.finditer(jsoncontent)
for i in datelist:
print(i.group())
break
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。