コード例 #1
0
    def img_search(self, img_key, dataSet, beginPage=1):
        """
        用于上传图片并搜索商品列表
        从1688官网图搜页面扒出来的jsonp接口
        :return: dict o None
        """
        app_name = "pc_tusou"

        app_key = base64.b64encode(f'{app_name};{dataSet}'.encode("utf-8"))

        appKey = str(app_key, encoding="utf8")

        request_params = {
            "imageAddress": img_key,
            "imageType": "oss",
            "pageSize": self.search_page_size,
            "beginPage": beginPage,
            "categoryId": "null",
            "appName": app_name,
            "appKey": appKey,
            "callback": ""
        }
        status_desc, data = request_get(self.imageSearch_service_url,
                                        request_params,
                                        headers=self.headers)
        if status_desc == "succ":
            return 'succ', data
        else:
            return 'fail', None
コード例 #2
0
    def get_dateset(self):
        '''
        获取加密时间
        :return:
        '''
        url = "https://open-s.1688.com/openservice/.htm?"  # 获取加密时间
        params = {
            "serviceIds": "cbu.searchweb.config.system.currenttime",
            "outfmt": "json",
        }

        status, data = request_get(url, params, self.headers)
        return status, data
コード例 #3
0
    def get_sign(self, data_set):
        '''
        用于获取 sign 用于加密
        :return:
        '''
        url = 'https://open-s.1688.com/openservice/ossDataService'
        appkey = "{};{}".format('pc_tusou', str(data_set))

        params = {
            "appName": "pc_tusou",
            "appKey": base64.b64encode(appkey.encode("utf-8")),
            # 发生变化 pc_tusou;1562288848391 b64 编码 pc_tusou;毫秒级时间戳
        }

        status, data = request_get(url, params, self.headers)

        data = data.get('data', {})

        signature = data.get('signature', '')
        policy = data.get('policy', '')
        accessid = data.get('accessid', '')

        return status, signature, policy, accessid
コード例 #4
0
    def get_sign(self, data_set):
        '''
        用于获取 sign 用于加密
        :return:
        '''
        url = 'https://open-s.1688.com/openservice/ossDataService'
        key = str(base64.b64decode("cGNfdHVzb3U=".encode("utf-8")), encoding="utf-8")
        appkey = "{};{}".format(key, str(data_set))

        params = {
            "appName": key,
            "appKey": base64.b64encode(appkey.encode("utf-8")),
        }

        status, data = request_get(url, params, self.headers)

        data = data.get('data', {})

        signature = data.get('signature', '')
        policy = data.get('policy', '')
        accessid = data.get('accessid', '')

        return status, signature, policy, accessid