forked from ylzon/python-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
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
mgss
committed
Nov 9, 2017
1 parent
fe96d0d
commit fc37a6e
Showing
4 changed files
with
40 additions
and
2 deletions.
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
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,32 @@ | ||
#!/usr/bin/env python | ||
# -*- coding:utf-8 -*- | ||
|
||
# 利用第三方接口实现输入QQ号判断是否在线 | ||
|
||
import requests | ||
from xml.etree import ElementTree as ET | ||
|
||
|
||
def is_online(qq_num): | ||
data = requests.get("http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx/qqCheckOnline?qqcode=%s" % qq_num) | ||
result = data.text | ||
node = ET.XML(result) | ||
|
||
return node.text | ||
|
||
|
||
def main(): | ||
inp = input("请输入要查询的QQ号:") | ||
result = is_online(inp) | ||
if result == "Y": | ||
print("[%s]在线" % inp) | ||
elif result == "N": | ||
print("[%s]离线" % inp) | ||
elif result == "E": | ||
print("QQ号码错误!") | ||
else: | ||
print("您输入的内容有误!") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |