我正在尝试在当地超市抓取产品的特定数据。该网站是https://www.veadigital.com.ar/Comprar/Home.aspx#_atCategory=false&_atGrilla=true&_id=446266 但是,我成功通过网站获取请求,但我的问题是设置具体超市的城市。默认城市是联邦首都。我检测到分析 cookie 的 id_local 是多少城市的超市,但我设置了一个特定的城市,例如 Bahía Blanca,但它不起作用。
如果我是手动用户,我可以更改单击“tu ubicacion”窗口中的位置(图中的黑色圆圈)。
图片网页:
我正在使用来自 python 的请求库。就像是一个aspx会话,我aspx从主网站获得了数字会话。
有任何想法吗?非常感谢,如果我的代码效率很低,我很抱歉。
我的代码
import re
import json
import requests
id_local="9122" #bahia blanca city
s = requests.Session() #because is aspx I used a Session
a=s.get("https://www.veadigital.com.ar/Login/PreHome.aspx")
response_header=dict(a.headers) #get reponse header
match = re.search('\w{16,}', responde_header['Set-Cookie'])
id_session=str(match[0]) #aspx id session
payload= {'IdMenu':446266,'textoBusqueda':"", 'producto':"", 'marca':"", 'pager':"", 'ordenamiento':'0', 'precioDesde':"", 'precioHasta':""}
head= {'Content-Type': 'application/json; charset=utf-8' ,
'cache-control': 'no-cache, max-age=0' ,'X-Requested-With': 'XMLHttpRequest' ,
'Origin': 'https://www.veadigital.com.ar' ,
'Connection': 'keep-alive' ,
'Referer': 'https://www.veadigital.com.ar/Login/PreHome.aspx' ,
'Cookie': 'ShopperCatch-d3d3LnZlYWRpZ2l0YWwuY29tLmFy-siteSaleChannelObjectType=variable; ShopperCatch-d3d3LnZlYWRpZ2l0YWwuY29tLmFy-siteSaleChannelObjectName=cc; ShopperCatch-d3d3LnZlYWRpZ2l0YWwuY29tLmFy-customCSS=https://console.shoppercatch.com/resources/client/veaar/custom-veaar.css; ShopperCatch-d3d3LnZlYWRpZ2l0YWwuY29tLmFy-customJS=https://console.shoppercatch.com/resources/client/veaar/custom-veaar.js; ShopperCatch-d3d3LnZlYWRpZ2l0YWwuY29tLmFy-customerUUID=b9c21c00-5edb-4ea7-81f2-0f44ce72d101; ASP.NET_SessionId='+ id_session + '; _gcl_au=1.1.1495116074.1616988170; _ga=GA1.3.1661999592.1616988176; _gid=GA1.3.1399531855.1616988176; _fbp=fb.2.1616988183823.774437577; _hjTLDTest=1; _hjid=4511e7e8-1d7c-4198-89e7-5427dd72d2c7; _idx={"idx":"Sh3e14Klws84FAtqZmiE6EIvIhdx16Jp5KX9lSuVOdzH2LC8cbAblS5TOkmiiN8FwaPsFlf1MyIITfZLRQnrn26Wz2uGtU12qxOuwX0fa4w=001ZJR9FP","t":"2021-03-29T03:43:54.022Z"}; _idxe=[{"id":"Sh3e14Klws84FAtqZmiE6EIvIhdx16Jp5KX9lSuVOdzH2LC8cbAblS5TOkmiiN8FwaPsFlf1MyIITfZLRQnrn26Wz2uGtU12qxOuwX0fa4w=001ZJR9FP","type":7,"w":0.3,"t":"2021-03-29T03:43:50.482627022Z"},{"id":"HE7f1YOgx89uRwxqMDSKvUV9IBMgi6Rr4/inkynGbtzBg7TvceZPkyEPOEn50YpRl6e+ElfwMCFdHKscQF6/y9omuZneRYQd+bwfXbdw8ww=001ZJR9FP","type":8,"w":0.25,"t":"2021-03-29T03:43:50.482627349Z"},{"id":"HByE1dbzxZ5jFVpvMWDU6xUvdRB21KVo5fjwk3iRad6Wi7fuKuNLkysPPU/0394Clfa4EwfzY3AKHvoeFQu8mS8KnAicFUGaSXPUZdX52Rg=001ZJR9FP","type":9,"w":0.225,"t":"2021-03-29T03:43:50.482627818Z"}]; latitud=null; longitud=null; noLocalizar=true; idLocalMasCercano=null; idLocalElegidoUsuario=' + id_local + '; _gat_UA-2998448-15=1; _gat_UA-2998448-6=1; _gat_UA-107982627-14=1'}
req=s.post("https://www.veadigital.com.ar/Comprar/HomeService.aspx/ObtenerArticulosPorDescripcionMarcaFamiliaLevex", headers=head, data=json.dumps(payload) , verify=False)
products= req.text # I get the prices and products but I receive data from Capital Federal city
print(products)
