Skip to content
This repository was archived by the owner on Oct 12, 2021. It is now read-only.

Commit f729012

Browse files
author
Super-Pershing
committed
add map
1 parent 1b89b8d commit f729012

File tree

8 files changed

+75662
-5
lines changed

8 files changed

+75662
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`printChatroomMemberName` is a boring homework program that work for USTC Internet of Things Technology course.
2+
TODO:`address` works with Echart

address.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
import webbrowser
2+
from collections import Counter
13
from urllib.request import urlopen, quote
24
import json
35
import requests
46
import itchat
57
from itchat.content import *
68

79
def getlnglat(address):
10+
'''
11+
返回字典形式的城市经纬度和其他信息数据
12+
'''
813
address = quote(address)
914
url = 'http://api.map.baidu.com/geocoder/v2/'
1015
output = 'json'
1116
ak = 'Uba11lIVgQGGj2xPZPif4mfRtNXjVhSo'
1217
uri = url + '?output=' + output + '&address=' + address + '&ak=' + ak
13-
# try:
1418
temp = urlopen(uri)
1519
temp = json.loads(temp.read().decode())
16-
# except:
17-
# temp = None
18-
# finally:
1920
return temp
2021

2122
@itchat.msg_register(itchat.content.TEXT)
@@ -25,13 +26,28 @@ def address_reply(msg):
2526
address = itchat.get_friends(update=False)
2627
print(type(address))
2728
address_list = ''
29+
address_json = dict()
30+
address_city_list = []
2831
for i in address:
2932
nickname = i["NickName"]
3033
city = i["City"]
3134
province = i["Province"]
3235
address_i = nickname + ':' + province + ' ' + city
3336
address_list += address_i + '\n'
34-
print(getlnglat(city))
37+
city_json = getlnglat(city) #type: <class 'dict'>
38+
if city_json['status'] == 0:
39+
address_city_list.append(city)
40+
print(city_json)
41+
address_json[city] = city_json
42+
elif city_json['status'] != 0:
43+
province_json = getlnglat(province) #type: <class 'dict'>
44+
if province_json['status'] == 0:
45+
address_city_list.append(province)
46+
print(province_json)
47+
address_json[province] = province_json
48+
49+
webbrowser.open('/home/tiger/Workspace/itChatAttendanceCheck/addressMap/index.html')
50+
print(address_json)
3551
itchat.send(address_list, source)
3652

3753
itchat.auto_login(hotReload=True)

0 commit comments

Comments
 (0)