----查看天气
import requests
response = requests.get("http://www.weather.com.cn/adat/sk/101010500.html")
response.encoding = "utf-8"
result = response.text
print(result)
输出:{"weatherinfo":{"city":"怀柔","cityid":"101010500","temp":"9","WD":"南风","WS":"1级","SD":"29%","WSE":"1","time":"10:25","isRadar":"1","Radar":"JC_RADAR_AZ9010_JB","njd":"暂无实况","qy":"1007"}}
#dic = json.load(result)
-----查看一个人的QQ是否在线
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import requests
r = requests.get('http://www.webxml.com.cn//webservices/qqOnlineWebService.asmx/qqCheckOnline?qqCode=496768192')
result = r.text #字符串类型
from xml.etree import ElementTree as ET
#解析XML格式内容
#XML接收一个参数:字符串,格式化为特殊对象
node = ET.XML(result)
#json。loads(result)
#获取内容
if node.text =='Y':
print("在线")
else:
print("离线")