Q:把京东数坊的数据拿到EXCEL里
管他用不用的上,都给他引上
from openpyxl import load_workbook
import requests
import json
import os
先拿个cookie再说
cookie = '__jdu******此处省略一万字'
再伪造个请求头
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36",
"cookie": cookie
}
找到4A数据,反手拿下来
def Get_4a(id, date, headers):
url = 'https://4a.******?brandCode={0}&endDate={1}&startDate={2}'.format(
id, date, date)
r = requests.get(url, headers=headers)
return r.json()
人群包数量级就用人群名称匹配,不打错字就能拿到手
def People(name, headers):
URL = 'https://4a.******List'
param = {
'name': name,
'startDate': '2019-03-31',
'endDate': '2022-03-30',
"audienceType": "all",
" pageSize": 100
}
r = requests.get(URL, headers=headers, params=param)
return r.json()
处理下4A数据,存在兜兜里
data_4a = [