|
@@ -0,0 +1,66 @@
|
|
|
|
+#!/usr/bin/env python
|
|
|
|
+# -*- encoding: utf-8 -*-
|
|
|
|
+'''
|
|
|
|
+@Contact : liuyuqi.gov@msn.cn
|
|
|
|
+@Time : 2023/06/09 01:46:55
|
|
|
|
+@License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
|
|
|
|
+@Desc : None
|
|
|
|
+'''
|
|
|
|
+import os,sys,re,logging
|
|
|
|
+import requests
|
|
|
|
+from lxml import etree
|
|
|
|
+from concurrent.futures import ThreadPoolExecutor
|
|
|
|
+import asyncio
|
|
|
|
+import aiohttp
|
|
|
|
+
|
|
|
|
+class Meituan(object):
|
|
|
|
+ ''' meituan spider '''
|
|
|
|
+
|
|
|
|
+ def __init__(self, cookie:str,url:str,url_path="conf/urls.txt" ) -> None:
|
|
|
|
+ self.url=url
|
|
|
|
+ self.sess=requests.session()
|
|
|
|
+ self.headers = {
|
|
|
|
+ 'Cookie': cookie,
|
|
|
|
+ 'Host': 'www.meituan.com',
|
|
|
|
+ 'Referer': 'https://www.meituan.com/',
|
|
|
|
+ "Content-Type": "application/x-www-form-urlencoded",
|
|
|
|
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36'
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ # https://i.waimai.meituan.com/openapi/v1/poi/food?_=1686248568250
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ def run(self):
|
|
|
|
+ # with ThreadPoolExecutor(max_workers=10) as executor:
|
|
|
|
+ # for i in range(1, 10):
|
|
|
|
+ # executor.submit(self.get_list, i)
|
|
|
|
+ uid="c3d2d2c0-4b5e-4b1e-8b0e-2b0b5b4b5b4b"
|
|
|
|
+ sid=re.findall(r"mtShopId=(\d+)", self.url)[0]
|
|
|
|
+ params = {
|
|
|
|
+ "page_offset": "0",
|
|
|
|
+ "page_size": "10",
|
|
|
|
+ "filter": "1",
|
|
|
|
+ "poiid": sid, # 替换成你要查询的商家ID
|
|
|
|
+ "type": "0",
|
|
|
|
+ "source": "1",
|
|
|
|
+ "platform": "1",
|
|
|
|
+ "append": "0",
|
|
|
|
+ "partner": "4",
|
|
|
|
+ "originUrl": "http://www.meituan.com/meishi/"
|
|
|
|
+ }
|
|
|
|
+ url="https://www.meituan.com/meishi/api/poi/getMerchantComment"
|
|
|
|
+ res=self.sess.post(url,headers=self.headers,data=params)
|
|
|
|
+ # save index.html
|
|
|
|
+ with open("index.html","w",encoding="utf-8") as f:
|
|
|
|
+ f.write(res.text)
|
|
|
|
+ print(res.text)
|
|
|
|
+
|
|
|
|
+ def get_list(self, page):
|
|
|
|
+ pass
|
|
|
|
+
|
|
|
|
+ def get_shop_info(self, shop_id):
|
|
|
|
+ pass
|
|
|
|
+
|
|
|
|
+ def save(self, data):
|
|
|
|
+ pass
|