python3使用pycurl库
来源:互联网 发布:提升淘宝搜索排名 编辑:程序博客网 时间:2024/06/08 05:11
Mac安装pycurl
源码下载地址http://pycurl.sourceforge.net
tar xvf pycurl-7.19.5.tar.gz cd pycurl-7.19.5 sudo python setup.py install
测试pycurl是否安装成功 ,命令行执行python
import pycurl
print pycurl.version
如果你使用是pycharm,可以直接到preference里安装,如下图
实例
这里的示例,实现一个从web server上下载一个文件到本地的功能,利用pycurl这个模块,直接上代码
__author__ = 'djstava' #!/usr/bin/env python#coding=utf-8import pycurlimport sysDJ_PYCURL_CONNECTTIMEOUT = 30DJ_PYCURL_TIMEOUT = 300DJ_PYCURL_DOWNLOADURL = "http://192.168.1.99/test.zip"DJ_PYCURL_DOWNLOAD_FILE = "download.file"fp = open(DJ_PYCURL_DOWNLOAD_FILE,'wb+')def dj_pycurl_writeFile(buffer): fp.write(buffer)def dj_pycurl_download(url): pycurl.global_init(pycurl.GLOBAL_ALL) c = pycurl.Curl() c.setopt(pycurl.URL, url) c.setopt(pycurl.WRITEDATA,fp) c.setopt(pycurl.WRITEFUNCTION,dj_pycurl_writeFile) c.setopt(pycurl.NOPROGRESS,0) c.setopt(pycurl.CONNECTTIMEOUT,DJ_PYCURL_CONNECTTIMEOUT) c.setopt(pycurl.TIMEOUT,DJ_PYCURL_TIMEOUT) c.setopt(pycurl.VERBOSE,1) c.perform() c.close() fp.close()if __name__ == '__main__': dj_pycurl_download(DJ_PYCURL_DOWNLOADURL)
代码测试
Mac安装nginx
brew install nginx
修改nginx配置文件
/usr/local/etc/nginx/nginx.conf
nginx默认根目录
/usr/local/opt/nginx/html
启动nginx服务
sudo nginx
References
1、http://pycurl.sourceforge.net
阅读全文
0 0
- python3使用pycurl库
- PycURL库使用
- python-pycurl库的使用
- 使用pycurl上传文件
- python pycurl 使用
- pycurl 使用 跳转
- Ubuntu-PycURL库安装
- PycURL
- pycurl
- 使用pycurl进行web提交
- python使用pycurl模块详解
- python使用pycurl模块详解
- pycurl和requests使用感受
- python使用pycurl模块详解
- python3 pycurl 出现 TypeError: string argument expected, got 'bytes' 解决方案
- Python3 codecs库基本使用
- python3.6安装pyspider出现的问题(pycurl安装失败)和解决方案
- 多线程使用pycurl时出现段错误(segmentation fault)
- 各种编码方式对比
- Android 布局
- HTML课堂讲义(2)
- 继承中的向上转型和向下转型
- 【Node.js】module.exports和exports的区别与使用
- python3使用pycurl库
- 最短路径
- 初识c语言
- 知识点总结(目录)
- 关于nodejs中密码加密的处理
- python3 里面的一些特性
- Linux常用命令
- 双链表C++
- 深度学习基础与TensorFlow实战(Chapter3笔记)