1 Star 0 Fork 0

XieYeMing/python爬虫与自动化脚本

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
京东.py 2.88 KB
一键复制 编辑 原始数据 按行查看 历史
XieYeMing 提交于 2024-02-16 17:44 . 练手脚本
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/xieyeming/machine-study.git
git@gitee.com:xieyeming/machine-study.git
xieyeming
machine-study
python爬虫与自动化脚本
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385