有人问:美团优选app当中有很多自提点,能不能导出?

我们来研究一下:批量获取这些自提点有什么办法呢?

通常我们要查找某个城市的美团优选中的商家自提点,一般是按照以下步骤操作:

  1. 打开美团应用程序。
  2. 进入应用后,可以通过点击“附近的自提点”选项来查找。
  3. 在搜索框中输入所在的城市或地区名称。
  4. 点击搜索按钮,系统会显示该地区内的自提点列表。

此外,还可以通过美团优选的微信小程序进行查找:

  1. 打开手机上的微信应用。
  2. 点击“发现”页面中的“小程序”。
  3. 搜索并打开“美团优选”小程序。
  4. 在小程序内选择“我的自提点”,然后通常可以查看到自提点的信息。

如下图:

1、附近自提点

2、搜索框搜索

抓取思路:分析/抓取数据包/解析/保存数据:

那么,按这个操作来说,我们下面要做的就是把系统显示的自提点也提取出来就是了。

我们找一个抓数据包的工具,来对显示的数据进行抓包。(比较复杂,步骤也比较多,专业性强,这里就略过了。)

我们来看一下原始数据:

{"code":0,"message":"success","data":{"historyOrderPoiIdList":[],"recommendPoiList":[{"poiId":0,"poiIdStr":"VPwCIInVDc_TZ8EOIvJTLQE","poiName":"绍兴老酒绿叶","picUrl":"https://img.meituan.net/groupheaduploadfiles/0b12b9a0bfbfa0cef83d7a810d76395b148990.jpg","address":"上海市宝山区同泰北路447号同泰北路447号绿叶市集菜市场内N4门面房  冰箱太小大件冷冻品是不能放","latitude":31.381681,"longitude":121.492451,"distance":1232.1,"distanceText":"距离1.23公里","cityId":1,"cityName":"上海","districtId":13,"poiBusinessStatus":1,"poiLabels":[{"type":6,"labelName":"优质服务","labelColor":"#FFE2BC","fontColor":"#FF7700","labelAttr":3,"displayType":1}],"poiLabelsV2":[{"type":6,"labelName":"优质服务","labelColor":"#FFE2BC","fontColor":"#FF7700","labelAttr":3,"displayType":1},{"type":9,"labelName":"送货上门、配送范围:点击查看地图","labelColor":"#D9D9D9","fontColor":"#000000","jumpUrl":"/subPackages/location/pages/receivingRange/index","labelAttr":1,"displayType":1}],"extraInfo":"{}","poiDeliveryInfo":{"deliveryRange":"配送范围:点击查看地图","deliveryRangeType":2,"isDelivery":1,"deliveryTypeText":"送货上门"}},{"poiId":0,"poiIdStr":"ztyKX8gO2E2VTrKY0WpYJQE","poiName":"荣港便利店","picUrl":"https://img.meituan.net/groupheaduploadfiles/d0a9d9081be9990482a4055ed323466242037145.jpg","address":"淞宝路677号荣港便利店(淞宝路店)淞宝路677号","latitude":31.389831,"longitude":121.502941,"distance":1265.0,"distanceText":"距离1.26公里","cityId":1,"cityName":"上海","districtId":13,"poiBusinessStatus":1,"poiLabels":[{"type":7,"labelName":"冷藏冷冻","labelColor":"#BFDFF0","fontColor":"#0A77F5","labelAttr":2,"displayType":1}],"poiLabelsV2":[{"type":7,"labelName":"冷藏冷冻","labelColor":"#BFDFF0","fontColor":"#0A77F5","labelAttr":2,"displayType":1}],"extraInfo":"{}","poiDeliveryInfo":{"isDelivery":0}},{"poiId":0,"poiIdStr":"6g2_78XtVgE9JyUpsVNvtgE","poiName":"领迪娱乐美团优选","picUrl":"https://img.meituan.net/groupheaduploadfiles/0c657837bb9aad9b2fdd24e40441e3fa34982212.jpg","address":"上海市宝山区密山路50号宝轻大厦(密山路)密山路50号4楼","latitude":31.402114,"longitude":121.482754,"distance":1268.5,"distanceText":"距离1.27公里","cityId":1,"cityName":"上海","districtId":13,"poiBusinessStatus":1,"poiLabels":[{"type":7,"labelName":"冷藏冷冻","labelColor":"#BFDFF0","fontColor":"#0A77F5","labelAttr":2,"displayType":1}],"poiLabelsV2":[{"type":7,"labelName":"冷藏冷冻","labelColor":"#BFDFF0","fontColor":"#0A77F5","labelAttr":2,"displayType":1}],"extraInfo":"{}","poiDeliveryInfo":{"isDelivery":0}},{"poiId":0,"poiIdStr":"7lqSGEGTqqVMIcgWRjeBsgE","poiName":"海江二村小店","picUrl":"https://img.meituan.net/groupheadfoundation/a2e9cdeaa3e452168cec351f5237f989280213.jpg","address":"上海市宝山区海江二村海江二村-71号楼海江二村71号小店","latitude":31.393637,"longitude":121.503581,"distance":1294.6,"distanceText":"距离1.29公里","cityId":1,"cityName":"上海","districtId":13,"poiBusinessStatus":1,"poiLabels":[{"type":6,"labelName":"优质服务","labelColor":"#FFE2BC","fontColor":"#FF7700","labelAttr":3,"displayType":1},{"type":4,"labelName":"支持冷藏","labelColor":"#3488FF","fontColor":"#3488FF","labelAttr":2,"displayType":1}],"poiLabelsV2":[{"type":6,"labelName":"优质服务","labelColor":"#FFE2BC","fontColor":"#FF7700","labelAttr":3,"displayType":1},{"type":4,"labelName":"支持冷藏","labelColor":"#3488FF","fontColor":"#3488FF","labelAttr":2,"displayType":1}],"extraInfo":"{}","poiDeliveryInfo":{"isDelivery":0}},{"poiId":0,"poiIdStr":"mmMFNRKId1e9ChRb37kM-QE","poiName":"手机检测维修","picUrl":"https://img.meituan.net/groupheaduploadfiles/5a053df2b8b7ce3578a4c2a82ce028302447178949.jpg","address":"上海市宝山区密山路88-3号手机检测维修密山路88号-2(手机检测维修)","latitude":31.401933,"longitude":121.481648,"distance":1312.5,"distanceText":"距离1.31公里","cityId":1,"cityName":"上海","districtId":13,"poiBusinessStatus":1,"poiLabels":[{"type":6,"labelName":"优质服务","labelColor":"#FFE2BC","fontColor":"#FF7700","labelAttr":3,"displayType":1},{"type":7,"labelName":"冷藏冷冻","labelColor":"#BFDFF0","fontColor":"#0A77F5","labelAttr":2,"displayType":1}],"poiLabelsV2":[{"type":6,"labelName":"优质服务","labelColor":"#FFE2BC","fontColor":"#FF7700","labelAttr":3,"displayType":1},{"type":7,"labelName":"冷藏冷冻","labelColor":"#BFDFF0","fontColor":"#0A77F5","labelAttr":2,"displayType":1}],"extraInfo":"{}","poiDeliveryInfo":{"isDelivery":0}}],"type":0,"groups":[{"group":"skinAB","strategy":"a"},{"group":"poiMapPageAB","strategy":"c"},{"group":"dragMapNoRelocateAB","strategy":"c"},{"group":"poiDisplayInfoOptABResult","strategy":"a"}],"nearbyLabelList":[{"type":7,"labelName":"冷藏冷冻","labelColor":"#BFDFF0","fontColor":"#0A77F5","labelAttr":2,"displayType":1},{"type":9,"labelName":"送货上门","labelColor":"#F20000","fontColor":"#F20000","labelAttr":1,"displayType":1},{"type":6,"labelName":"优质服务","labelColor":"#FFE2BC","fontColor":"#FF7700","labelAttr":3,"displayType":1}],"total":40,"offset":35,"limit":5,"hitMtsi":false,"nearbyPoiDefaultSelectIndex":0}}

然后我们要做的就是把数据解析出来:

                
poi_list = json.loads(data)
poi = poi_list['data']['recommendPoiList']
for pp in poi:
    poiName = pp['poiName']
    picUrl = pp['picUrl']
    address = pp['address']
    poiIdStr = pp['poiIdStr']
    poiLabels = ';'.join(l['labelName'] for l in pp['poiLabels'])
    print(poiName, poiLabels)

解析出来以后保存即可:

with open(f'{c_time}_美团优选自提点.csv', 'a', encoding='ANSI') as f:
   f.write(f"{poiName}, {picUrl}, {address}, {poiIdStr}, {poiLabels}, {pp['latitude']}, {pp['longitude']}, \n")

基本的数据抓取和解析、保存就这样了,下面如果要批量获取,就需要去研究如何进行翻页,在代码基础上加上翻页或者切换不同地址进行获取的逻辑了。下图是保存以后的表格截图。



文章来源:想要某个城市的美团优选当中的商家自提点,要怎么做呢 | 美团优选商家自提点数据抓取尝试 – 富泰科 (futaike.net),作者微信:futaike_corp,版权所有,转载请保留。



微信扫描下方的二维码阅读本文

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注