标签:user sts port requests ice get ati text 参数
1安装
软件管理工具
安装pip3
依赖setuptools
pip3 install requests
2源码安装
下载代码,安装
https://codeload.github.com/requests/requests/legacy.tar.gz/master
先下载然后解太进入目录中,执行
python setup.py install
1 import requests 2 response = requests.get("http://www.weather.com.cn/adat/sk/101010500.html") 3 response.encoding = "utf-8" 4 result =response.text 5 print(result)
检查QQ是否在线
1 import requests 2 #发送一个requests http请求,或者XML格式内容 3 r = requests.get("http://www.webxml.com.cn//webservices/qqOnlineWebService.asmx/qqCheckOnline?qqCode=45678966456") 4 result = r.text 5 from xml.etree import ElementTree as ET 6 #解析XML格式内容 7 #XML接收一个参数:字符串,格式化为特殊的对像 8 node = ET.XML(result) 9 #获取内容 10 if node.text == "Y": 11 print("在线") 12 else: 13 print("离线")
火车时刻列表
1 import requests 2 r = requests.get("http://ws.webxml.com.cn/WebServices/TrainTimeWebService.asmx/getDetailInfoByTrainCode?TrainCode=T96&UserID=") 3 result = r.text 4 # print(result) 5 from xml.etree import ElementTree as ET 6 root = ET.XML(result) 7 for node in root.iter("TrainDetailInfo"): 8 print(node.find(‘TrainStation‘).text,node.find(‘ArriveTime‘).text)
标签:user sts port requests ice get ati text 参数
原文地址:http://www.cnblogs.com/wang43125471/p/7717524.html