Skip to content

Commit

Permalink
添加垃圾分类查询
Browse files Browse the repository at this point in the history
  • Loading branch information
sfyc23 committed Jul 13, 2019
1 parent f1c3b0d commit 41d50cd
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions everyday_wechat/control/rubbish/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
"""
Project: EverydayWechat-Github
Creator: DoubleThunder
Create time: 2019-07-14 01:00
Introduction:
"""


39 changes: 39 additions & 0 deletions everyday_wechat/control/rubbish/atoolbox_rubbish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
"""
Project: EverydayWechat-Github
Creator: DoubleThunder
Create time: 2019-07-14 01:02
Introduction: http://www.atoolbox.net/Tool.php?Id=804
"""

import requests
from everyday_wechat.utils.common import SPIDER_HEADERS


def get_atoolbox_rubbish(key):
"""
# http://www.atoolbox.net/Tool.php?Id=804
:param key:
:return:
"""
params = {'key': key}
resp = requests.get('http://www.atoolbox.net/api/GetRefuseClassification.php',
headers=SPIDER_HEADERS,
params=params)

if resp.status_code == 200:
# print(resp.text)
content_dict = resp.json()
if not content_dict:
return None, None, None
return_list = list(content_dict.values())
_type = ''
for rl in return_list:
if key == rl['name']:
_type = rl['type']
break
other = ''
if not _type:
other = ' '.join(i['name'] for i in return_list[:6])
return _type, return_list, other
return None, None, None

0 comments on commit 41d50cd

Please sign in to comment.