问题 Web 抓取 Python ASPX 特定请求

问题描述

我正在尝试抓取当地超市中产品的特定数据。 该网站是https://www.veadigital.com.ar/Comprar/Home.aspx#_atCategory=false&_atGrilla=true&_id=446266 但是,我成功通过网站获取请求,但我的问题是设置了超市的特定城市。认城市是首都联邦。我检测到分析 cookie id_local 如何与超市城市的数量有关,但我设置了一个特定的城市,例如Bahía Blanca,但它没有用。

如果我是手动用户,我可以在“tu ubicacion”窗口(图片中的黑色圆圈)中单击更改位置。

图片网页:

enter image description here

我正在使用来自 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)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)