def get_shop_restaurants_menu(self, lat, lng, shopId, session): url = ' https://restapi.ele.me/shopping/v2/menu?restaurant_id={}'.format( shopId) headers = copy(self.headers) result = self.sneer(url) headers.update({ 'x-shard': 'loc={},{}'.format(lng, lat), 'x-eleme-requestid': '{}|{}'.format(tool.gen_uuid().upper().replace('-', ''), tool.get_timestamp()), 'random': '{}'.format(result[0]), 'deadpoolcontent': '{}'.format(result[1]), 'deadpool': '{}'.format(result[2]), }) try: resp = session.get(url, headers=headers, proxies=self.proxy, timeout=3) return resp.json() except requests.exceptions.ConnectTimeout: self.proxy = tool.get_proxy(self.local_proxy) return None except: log.exception('login_by_mobile error.') return None
def get_captcha(self, mobile, lat, lng): url = 'https://restapi.ele.me/eus/v4/captchas?captcha_str={}'.format( mobile) headers = copy(self.headers) result = self.sneer(url) headers.update({ 'x-shard': 'loc={},{}'.format(lng, lat), 'x-eleme-requestid': '{}|{}'.format(tool.gen_uuid().upper().replace('-', ''), tool.get_timestamp()), 'ex_r': '{}'.format(result[0]), 'ex_dc': '{}'.format(result[1]), 'ex_d': '{}'.format(result[2]), }) headers.pop('content-type') try: resp = self.s.get(url, headers=headers, proxies=self.proxy, timeout=3) return resp.json() except requests.exceptions.ConnectTimeout: self.proxy = tool.get_proxy(self.local_proxy) return None except: log.exception('get_captcha error.') return None
def get_shop_restaurants_test(self, lat, lng, shopId, session): url = ' https://restapi.ele.me/shopping/restaurant/{}?extras[]=activities&extras[]=flavors&extras[]=albums&extras[]=videos&extras[]=coupon&extras[]=qualification&latitude={}&longitude={}'.format( shopId, lat, lng) headers = copy(self.headers) result = self.sneer(url) headers.update({ 'x-shard': 'loc={},{}'.format(lng, lat), 'x-eleme-requestid': '{}|{}'.format(tool.gen_uuid().upper().replace('-', ''), tool.get_timestamp()), 'random': '{}'.format(result[0]), 'deadpoolcontent': '{}'.format(result[1]), 'deadpool': '{}'.format(result[2]), }) try: resp = session.get(url, headers=headers, proxies=self.proxy, timeout=3) return resp.status_code, resp.json() except requests.exceptions.ConnectTimeout: self.proxy = tool.get_proxy(self.local_proxy) return None except: log.exception('login_by_mobile error.') return None
def get_restaurants_test(self, lat, lng, city_id, order_by, offset, seesion): url = 'https://restapi.ele.me/shopping/v3/restaurants?extras[]=identification&extras[]=coupon&' \ 'latitude={}&longitude={}&city_id={}&rank_id={}&network_operator=&network=WIFI&order_by={}&' \ 'extra_filters=home&os=Android%2F{}&deivce={}&weather_code=CLEAR_DAY&offset={}&limit=20'.format( lat, lng, city_id, tool.gen_random_af(32), order_by, self.dv_params.get('RELEASE'), parse.quote(self.dv_params.get('MODEL')), offset ) headers = copy(self.headers) result = self.sneer(url) headers.update({ 'x-shard': 'loc={},{}'.format(lng, lat), 'x-eleme-requestid': '{}|{}'.format(tool.gen_uuid().upper().replace('-', ''), tool.get_timestamp()), 'ex_r': '{}'.format(result[0]), 'ex_dc': '{}'.format(result[1]), 'ex_d': '{}'.format(result[2]), }) try: resp = seesion.get(url, headers=headers, proxies=self.proxy, timeout=10) return resp.status_code, resp.json() except requests.exceptions.ConnectTimeout: self.proxy = tool.get_proxy(self.local_proxy) return None except: log.exception('login_by_mobile error.') return None
def random_useragent_eleme(self): kernal_ver = ['3.4.39', '3.10.0', '3.16.1', '3.18.10', '4.4.1'] return 'Rajax/1 {}/{} Android/{} Display/{} Eleme/{} Channel/moxiu ID/{}; KERNEL_VERSION:{} API_Level:{} Hardware:{}'.format( tool.replace_blank(self.dv_params.get('MODEL')), tool.replace_blank(self.dv_params.get('PRODUCT')), tool.replace_blank(self.dv_params.get('RELEASE')), tool.replace_blank(self.dv_params.get('DISPLAY')), self.version, tool.gen_uuid(), random.choice(kernal_ver) + '-g8bac269', tool.replace_blank(self.dv_params.get('SDK_INT')), self.hardware_id)
def mobile_send_code_captcha(self, mobile, lat, lng, captcha_hash, captcha_value): url = 'https://restapi.ele.me/eus/login/mobile_send_code' headers = copy(self.headers) result = self.sneer(url) headers.update({ 'x-shard': 'loc={},{}'.format(lng, lat), 'x-eleme-requestid': '{}|{}'.format(tool.gen_uuid().upper().replace('-', ''), tool.get_timestamp()), 'ex_r': '{}'.format(result[0]), 'ex_dc': '{}'.format(result[1]), 'ex_d': '{}'.format(result[2]), }) data = '{"mobile":"%s","captcha_hash":"%s","captcha_value":"%s","latitude":%s,"longitude":%s,"via_audio":false}' % ( str(mobile), str(captcha_hash), str(captcha_value), str(lat), str(lng), ) try: resp = self.s.post(url, headers=headers, data=data, proxies=self.proxy, timeout=3) return resp.json() except requests.exceptions.ConnectTimeout: self.proxy = tool.get_proxy(self.local_proxy) return None except: log.exception('mobile_send_code_captcha error.') return None
def get_restaurants_all_id(self, lat, lng, city_id, order_by, categorys, offset, seesion): url = 'https://restapi.ele.me/shopping/v3/restaurants?extras[]=coupon&latitude={}&longitude={}&city_id={}&rank_id=&business_flag=0&order_by={}&{}offset={}&limit=20'.format( lat, lng, city_id, order_by, categorys, offset) Flag = self.r.has_url(url) if not Flag: log.info('重复的url') return None log.info(url) headers = copy(self.headers) result = self.sneer(url) headers.update({ 'x-shard': 'loc={},{}'.format(lng, lat), 'x-eleme-requestid': '{}|{}'.format(tool.gen_uuid().upper().replace('-', ''), tool.get_timestamp()), 'ex_r': '{}'.format(result[0]), 'ex_dc': '{}'.format(result[1]), 'ex_d': '{}'.format(result[2]), }) try: resp = seesion.get(url, headers=headers, proxies=self.proxy, timeout=10) return resp.json() except requests.exceptions.ConnectTimeout: self.proxy = tool.get_proxy(self.local_proxy) return None except: log.exception('login_by_mobile error.') return None
def get_restaurants(self, lat, lng, city_id, order_by, offset): url = 'https://restapi.ele.me/shopping/v3/restaurants?extras[]=identification&extras[]=coupon&' \ 'latitude={}&longitude={}&city_id={}&rank_id={}&network_operator=&network=WIFI&order_by={}&' \ 'extra_filters=home&os=Android%2F{}&deivce={}&weather_code=CLEAR_DAY&offset={}&limit=20'.format( lat, lng, city_id, tool.gen_random_af(32), order_by, self.dv_params.get('RELEASE'), parse.quote(self.dv_params.get('MODEL')), offset ) url = 'https://restapi.ele.me/shopping/v3/restaurants?extras[]=coupon&latitude=31.243828888982534&longitude=121.48247290402651&city_id=1&rank_id=&business_flag=0&restaurant_category_ids%5B%5D=1&offset=0&limit=20' url = 'https://restapi.ele.me/shopping/v3/restaurants?extras[]=coupon&latitude=30.725792&longitude=121.268812&city_id=1&rank_id=&business_flag=0&order_by=5&restaurant_category_ids%5B%5D=4&offset=0&limit=20' headers = copy(self.headers) result = self.sneer(url) headers.update({ 'x-shard': 'loc={},{}'.format(lng, lat), 'x-eleme-requestid': '{}|{}'.format(tool.gen_uuid().upper().replace('-', ''), tool.get_timestamp()), 'ex_r': '{}'.format(result[0]), 'ex_dc': '{}'.format(result[1]), 'ex_d': '{}'.format(result[2]), }) try: resp = self.s.get(url, headers=headers, proxies=self.proxy, timeout=3) return resp.json() except requests.exceptions.ConnectTimeout: self.proxy = tool.get_proxy(self.local_proxy) return None except: log.exception('login_by_mobile error.') return None
def login_by_mobile(self, token, sms_code, lat, lng): url = 'https://restapi.ele.me/eus/login/login_by_mobile' headers = copy(self.headers) result = self.sneer(url) headers.update({ 'x-shard': 'loc={},{}'.format(lng, lat), 'x-eleme-requestid': '{}|{}'.format(tool.gen_uuid().upper().replace('-', ''), tool.get_timestamp()), 'ex_r': '{}'.format(result[0]), 'ex_dc': '{}'.format(result[1]), 'ex_d': '{}'.format(result[2]), }) data = '{"validate_token":"%s","validate_code":"%s","latitude":%s,"longitude":%s}' % ( str(token), str(sms_code), str(lat), str(lng), ) try: resp = self.s.post(url, headers=headers, data=data, proxies=self.proxy, timeout=3) return self.s.cookies except requests.exceptions.ConnectTimeout: self.proxy = tool.get_proxy(self.local_proxy) return None except: log.exception('login_by_mobile error.') return None