nawawa001 发表于 2018-8-16 07:58:55

Python中的get请求

  网站是在vmware虚拟机里搭了一个Tomcat的jspgou网站。

  py代码:
import requests  
html =requests.get('http://192.168.171.144:8080/')
  
print html.text
  
print html.status_code
  
print html.headers['content-type']
  这是使用了requests第三方包(导包教程请点击)
  使用urllib2的话 用于py2.1以后版本(urllib是1.4以后版本都可以)
import urllib2  
url = "http://192.168.171.144:8080/"
  
res_data = urllib2.urlopen(urllib2.Request(url))
  
res = res_data.read()
  
print res
页: [1]
查看完整版本: Python中的get请求