python获取url的返回信息方法

yipeiwu_com6年前Python基础

如下所示:

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 
import os
import sys
import urllib
import urllib2
import string
#########start 获取url的返回信息############
def jwkj_url_postget(url,vlaues):
 data = urllib.urlencode(values)
 req = urllib2.Request(url, data)
 response = urllib2.urlopen(req)
 str = response.read()
 return str
#########end 获取url的返回信息############
if __name__ == "__main__": 
 print jwkj_url_postget('http://localhost/getTextAd.php',{'pmac':'001122334466'})

以上这篇python获取url的返回信息方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python django使用多进程连接mysql错误的解决方法

Python django使用多进程连接mysql错误的解决方法

问题 mysql 查询出现错误 error: (2014, "Commands out of sync; you can't run this command now")1 查询 m...

使用Protocol Buffers的C语言拓展提速Python程序的示例

 Protocol Buffers (类似XML的一种数据描述语言)最新版本2.3里,protoc—py_out命令只生成原生的Python代码。 尽管PB(Protocol...

如何修复使用 Python ORM 工具 SQLAlchemy 时的常见陷阱

在使用 SQLAlchemy 时,那些看似很小的选择可能对这种对象关系映射工具包的性能产生重要影响。 对象关系映射Object-relational mapping(ORM)使应用程序开...

详细解读Python中解析XML数据的方法

Python可以使用 xml.etree.ElementTree 模块从简单的XML文档中提取数据。 为了演示,假设你想解析Planet Python上的RSS源。下面是相应的代码:...

Pytorch实现神经网络的分类方式

本文用于利用Pytorch实现神经网络的分类!!! 1.训练神经网络分类模型 import torch from torch.autograd import Variable imp...