既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
该请求为一个POST请求,对应的数据为:
data = {'wm\_dtype': 'microsoft',
'wm\_dversion': '7.0.9',
'wm\_uuid': 'xxx',
'wm\_visitid': 'xxx',
'wm\_appversion': '5.13.26',
'wm\_logintoken': 'xxx',
'userToken': 'xxx',
'req\_time': 1613274108532,
'waimai\_sign': '%2F',
'wm\_longitude': 116938974,
'wm\_latitude': 30109265,
'wm\_actual\_longitude': 0,
'wm\_actual\_latitude': 0,
'userid': 'xxx',
'user\_id': 'xxx',
'uniqueid': 'xxx',
'open\_id': 'xxx',
'openidcipher': 'xxx',
'uuid': 'xxx',
'rc\_platform': 13,
'platform': 13,
'rc\_app': 0,
'partner': 214,
'riskLevel': 71,
'keyword': '鲜花',
'page\_index': 0,
'category\_type': 101578,
'entrance\_id': 101578,
'sort\_type': 0,
'search\_global\_id': '274108528141A972426FC37CA2E81D27BA604D85428455EA33E345156F93CDB59C024AE9F',
'wm\_ctype': 'mt\_weapp'}
注:xxx代表用户登录状态以及校验等相关参数,我们大可不必深究它们是怎么生成的,直接从Fiddler中将其复制出来即可~
其中,keyword表示搜索的关键词,page_index表示搜索结果的页码(每次返回20条数据),wm_longitude和wm_latitude分别表示用户所在的经纬度。通过测试可以知道,我们只需要改变经纬度便能得到不同地区的数据,那么可以定义如下函数:
def get\_info(keyword, pos, page=0):
'''
获取外卖商品信息
'''
url = 'https://wx-shangou.meituan.com/mtweapp/v2/search/v9/poiwithfilter?ui=xxx'
headers = {} # 从Fiddler直接复制即可
data = {'wm\_dtype': 'microsoft',
'wm\_dversion': '7.0.9',
'wm\_uuid': 'xxx',
'wm\_visitid': 'xxx',
'wm\_appversion': '5.13.26',
'wm\_logintoken': 'xxx',
'userToken': 'xxx',
'req\_time': 1613274108532,
'waimai\_sign': '%2F',
'wm\_longitude': int(pos[0]\*10\*\*6),
'wm\_latitude': int(pos[1]\*10\*\*6),
'wm\_actual\_longitude': 0,
'wm\_actual\_latitude': 0,
'userid': 'xxx',
'user\_id': 'xxx',
'uniqueid': 'xxx',
'open\_id': 'xxx',
'openidcipher': 'xxx',
'uuid': 'xxx',
'rc\_platform': 13,
'platform': 13,
'rc\_app': 0,
'partner': 214,
'riskLevel': 71,
'keyword': keyword,
'page\_index': page,
'category\_type': 101578,
'entrance\_id': 101578,
'sort\_type': 0,
'search\_global\_id': '274108528141A972426FC37CA2E81D27BA604D85428455EA33E345156F93CDB59C024AE9F',
'wm\_ctype': 'mt\_weapp'}
res = requests.post(url, headers=headers, data=data)
res_json = res.json()
return res_json
然而,我们要怎样才能得到城市对应的经纬度呢?
2.获取城市经纬度
通过高德地图的坐标捡拾系统,便能实现地理位置与经纬度的转换。由于接口很简单,这里就不详细介绍了,同样是通过抓包分析,可以定义如下转换函数:
def get\_lonlat(keywords):
'''
获取经纬度
'''
cookies = {
'cna': '2voBF5IOjUUCAXWIWXVuwr8W',
'UM\_distinctid': '1767bba477b6bd-00c663bca533b3-1a347740-e1000-1767bba477c515',
'isg': 'BGhoxgK9o-s-8I9R8e9xGWcsOlZ6kcybbxhnvCKZpePsfQjn1qD8K\_v0cZWN1oRz',
'l': 'eBOY0AmuO96VEuAdBOfalurza779\_IOYYuPzaNbMiOCP\_CCp5q8cWZ-AMOL9Cn1Vh6UXc37LhhQJBeYBqMIKnxvOKVLdi6Mmn',
'tfstk': 'cFtVBg4K3mnq\_Csdmisa5HrbndsAZ8QG8uWOoFwkl8RrRN\_li2NOE50PU9UjqZf..',
}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0',
'Accept': '\*/\*',
'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
'Referer': 'https://lbs.amap.com/console/show/picker',
'Connection': 'keep-alive',
}
params = (
('s', 'rsv3'),
('children', ''),
('key', 'e07ffdf58c8e8672037bef0d6cae7d4a'),
('page', '1'),
('offset', '10'),
('city', '110000'),
('language', 'zh\_cn'),
('callback', 'jsonp\_160108\_'),
('platform', 'JS'),
('logversion', '2.0'),
('sdkversion', '1.3'),
('appname', 'https://lbs.amap.com/console/show/picker'),
('csid', '6DCF386C-8777-4724-AE49-8E688CCEF75A'),
('keywords', keywords),
)
res = requests.get('https://restapi.amap.com/v3/place/text', headers=headers, params=params, cookies=cookies)
html = res.text
data = re.findall('\((.\*)\)',html)[0]
data = json.loads(data)
location = data['pois'][0]['location']
lon = float(location.split(',')[0])
lat = float(location.split(',')[1])
return (lon, lat)
3.完整代码
从每个省级行政区中选出一个城市(即省会),创建一个txt用于将其存储:
完整的数据爬取代码如下:
# -\*- coding: utf-8 -\*-
"""
Created on Sun Feb 14 11:54:59 2021
@author: kimol\_love
"""
import os
import re
import json
import requests
import pandas as pd
def get\_info(keyword, pos, page=0):
'''
获取外卖商品信息
'''
url = 'https://wx-shangou.meituan.com/mtweapp/v2/search/v9/poiwithfilter?ui=xxx' # xxx处需要相应改
headers = {'Connection': 'keep-alive',
'Content-Length': '1191',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat',
'\_deferreds': '[object Array]',
'content-type': 'application/x-www-form-urlencoded',
'uuid': 'xxx',
'wm-ctype': 'mt\_weapp',
'Accept-Encoding': 'gzip, deflate, br'}
data = {'wm\_dtype': 'microsoft',
'wm\_dversion': '7.0.9',
'wm\_uuid': 'xxx',
'wm\_visitid': 'xxx',
'wm\_appversion': '5.13.26',
'wm\_logintoken': 'xxx',
'userToken': 'xxx',
'req\_time': 1613274108532,
'waimai\_sign': '%2F',
'wm\_longitude': int(pos[0]\*10\*\*6),
'wm\_latitude': int(pos[1]\*10\*\*6),
'wm\_actual\_longitude': 0,
'wm\_actual\_latitude': 0,
'userid': 'xxx',
'user\_id': 'xxx',
'uniqueid': 'xxx',
'open\_id': 'xxx',
'openidcipher': 'xxx',
'uuid': 'xxx',
'rc\_platform': 13,
'platform': 13,
'rc\_app': 0,
'partner': 214,
'riskLevel': 71,
'keyword': keyword,
'page\_index': page,
'category\_type': 101578,
'entrance\_id': 101578,
'sort\_type': 0,
'search\_global\_id': 'xxx',
'wm\_ctype': 'mt\_weapp'}
res = requests.post(url, headers=headers, data=data)
res_json = res.json()
return res_json
def parse\_info(data):
'''
提取所需数据
'''
result = [] # 用于保存结果
for poi in data['data']['search\_poi\_list']:
name = poi['name'] # 商店名称
sales = int(poi['month\_sales\_tip'][2:]) # 月销量
address = poi['address'] # 地址
lon = int(poi['longitude'])/10\*\*6 # 经度
lat = int(poi['latitude'])/10\*\*6 # 纬度
result.append({'商店名': name,
'月销量': sales,
'地址': address,
'经度': lon,
'纬度': lat})
return result
def get\_lonlat(keywords):
'''
获取经纬度
'''
cookies = {
'cna': '2voBF5IOjUUCAXWIWXVuwr8W',
'UM\_distinctid': '1767bba477b6bd-00c663bca533b3-1a347740-e1000-1767bba477c515',
'isg': 'BGhoxgK9o-s-8I9R8e9xGWcsOlZ6kcybbxhnvCKZpePsfQjn1qD8K\_v0cZWN1oRz',
'l': 'eBOY0AmuO96VEuAdBOfalurza779\_IOYYuPzaNbMiOCP\_CCp5q8cWZ-AMOL9Cn1Vh6UXc37LhhQJBeYBqMIKnxvOKVLdi6Mmn',
'tfstk': 'cFtVBg4K3mnq\_Csdmisa5HrbndsAZ8QG8uWOoFwkl8RrRN\_li2NOE50PU9UjqZf..',
}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0',
'Accept': '\*/\*',
'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
'Referer': 'https://lbs.amap.com/console/show/picker',
'Connection': 'keep-alive',
}
params = (
('s', 'rsv3'),
('children', ''),
('key', 'e07ffdf58c8e8672037bef0d6cae7d4a'),
('page', '1'),
('offset', '10'),
('city', '110000'),
('language', 'zh\_cn'),
('callback', 'jsonp\_160108\_'),
('platform', 'JS'),
('logversion', '2.0'),
('sdkversion', '1.3'),
('appname', 'https://lbs.amap.com/console/show/picker'),
('csid', '6DCF386C-8777-4724-AE49-8E688CCEF75A'),
('keywords', keywords),
)
res = requests.get('https://restapi.amap.com/v3/place/text', headers=headers, params=params, cookies=cookies)
html = res.text
data = re.findall('\((.\*)\)',html)[0]
data = json.loads(data)
location = data['pois'][0]['location']
lon = float(location.split(',')[0])
lat = float(location.split(',')[1])
return (lon, lat)
if __name__ == '\_\_main\_\_':
# 读取城市列表
with open('citys.txt', 'r') as f:
citys = f.readlines()
![img](https://img-blog.csdnimg.cn/img_convert/d79eb206eaab142433d90ad04c2c589c.png)
![img](https://img-blog.csdnimg.cn/img_convert/b005847b00c44a0c76c6490c73a0c70f.png)
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**[需要这份系统化的资料的朋友,可以添加戳这里获取](https://bbs.csdn.net/topics/618658159)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
Yw-1715821906744)]
[外链图片转存中...(img-WRQZNz9T-1715821906745)]
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**[需要这份系统化的资料的朋友,可以添加戳这里获取](https://bbs.csdn.net/topics/618658159)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**