文档库 最新最全的文档下载
当前位置:文档库 › eoLinker-API_Shop_淘宝热词查询_API接口_Python调用示例代码

eoLinker-API_Shop_淘宝热词查询_API接口_Python调用示例代码

eoLinker-API_Shop_淘宝热词查询_API接口_Python调用示例代码
eoLinker-API_Shop_淘宝热词查询_API接口_Python调用示例代码

eoLinker-API Shop 淘宝热词查询 Python调用示例代码

淘宝热词查询

根据用户输入的关键词,实时查询该词在全站的搜索排名,协助商家全面掌控搜索关键词近期的市场排名,分布特征等。

该产品拥有以下APIs:

1.淘宝热搜查询

注意,该示例代码仅适用于https://www.wendangku.net/doc/1a10118927.html,网站下API使用该产品前,您需要通过https://https://www.wendangku.net/doc/1a10118927.html,/#/api/detail/?productID=212申请API服务

1.淘宝热搜查询

#!/usr/bin/env python

# -*- coding: utf-8 -*-

# 测试环境: python2.7

# 安装requests依赖 => pip install requests/ easy_install requests

# 导入requests依赖

import requests

import json

import sys

reload(sys)

sys.setdefaultencoding('utf-8')

def apishop_send_request(method, url, params=None, headers=None):

'''

转发请求到目的主机

@param method str 请求方法

@param url str 请求地址

@param params dict 请求参数

@param headers dict 请求头

'''

method = str.upper(method)

if method == 'POST':

return requests.post(url=url, data=params, headers=headers)

elif method == 'GET':

return requests.get(url=url, params=params, headers=headers)

else:

return None

method = "POST"

url = "https://https://www.wendangku.net/doc/1a10118927.html,/common/shopping/queryTBRelatedHotWords" headers = None

params = {

"apiKey":"your_api_key", #需要从https://www.wendangku.net/doc/1a10118927.html,获取

"keyword":"" #查询关键字

}

result = apishop_send_request(method=method, url=url, params=params, he aders=headers)

if result:

body = result.text

response = json.loads(body)

status_code = response["statusCode"]

if (status_code == '000000'):

# 状态码为000000, 说明请求成功

print('请求成功:%s' % (body,))

else:

# 状态码非000000, 说明请求失败

print('请求失败: %s' % (body,))

else:

# 返回内容异常,发送请求失败

print('发送请求失败')

相关文档