Skip to content

Commit

Permalink
0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
justinzm committed Feb 19, 2021
1 parent daca86f commit ae1f103
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ print(df)
- 谷歌指数数据
- 谷歌指数数据
- 谷歌事实查证
- 搜狗指数数据
- 搜狗指数趋势数据
- 宏观数据
- 中国宏观数据
- 中国宏观杠杆率数据
Expand Down Expand Up @@ -108,6 +110,9 @@ print(df)

#### 版本更新

0.3.3
指数数据:搜狗指数趋势数据

0.3.2
中国宏观数据: 工业增加值增长、财政收入、社会消费品零售总额、信贷数据、外商直接投资数据(FDI)
迭代百度迁入与迁出地详情
Expand Down
4 changes: 4 additions & 0 deletions gopup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"""
from gopup.index.index_weibo import weibo_index

"""
搜狗指数
"""
from gopup.index.index_sogou import sogou_index

"""
头条指数
Expand Down
40 changes: 40 additions & 0 deletions gopup/index/index_sogou.py
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")

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

URL = 'https://github.com/justinzm/gopup'
NAME = 'gopup'
VERSION = '0.3.2'
VERSION = '0.3.3'
DESCRIPTION = 'GoPUP database'
if os.path.exists('README.md'):
with open('README.md', encoding='utf-8') as f:
Expand Down

0 comments on commit ae1f103

Please sign in to comment.