-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# @Time : 2021/2/19 0019 | ||
# @Author : justin.郑 [email protected] | ||
# @File : index_sogou.py | ||
# @Desc : 搜狗指数 | ||
|
||
import json | ||
import pandas as pd | ||
import requests | ||
from gopup.index.cons import index_toutiao_headers | ||
|
||
|
||
def sogou_index(keyword, start_date, end_date, data_type="SEARCH_ALL"): | ||
""" | ||
搜狗指数趋势数据 | ||
:param keyword: 关键词 | ||
:param start_date: 开始日期 | ||
:param end_date: 截止日期 | ||
:param data_type: 指数趋势 | ||
:return: | ||
datetime 日期 | ||
index 指数 | ||
""" | ||
|
||
# SEARCH_ALL 整体趋势 SEARCH_PC PC趋势 SEARCH_WAP 移动趋势 | ||
|
||
url = "http://zhishu.sogou.com/getDateData?kwdNamesStr=%s&startDate=%s&endDate=%s&dataType=%s&queryType=INPUT" % (keyword, start_date, end_date, data_type) | ||
|
||
res = requests.get(url, headers=index_toutiao_headers) | ||
pv_list = json.loads(res.text)['data']['pvList'][0] | ||
df = pd.DataFrame(pv_list) | ||
df['index'] = df['pv'] | ||
df = df.drop(['kwdId', 'isPeak', 'id', 'pv'], axis=1) | ||
return df | ||
|
||
|
||
if __name__ == "__main__": | ||
sogou_index(keyword="耐克", start_date="20210101", end_date="20210218") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters