2012年8月16日星期四
2012年8月15日星期三
virtualbox secureCRT 配置(fedora)
http://www.cnblogs.com/songxk/archive/2012/02/08/2342611.html
本文用的方式是NAT+HostOnly 方式,与上一种相比,不用太多的配置。
1,VirtualBox中的网络,第一个选择NAT,默认选项。第二个选择HostOnly,高级配置中,混杂模式设为全部允许(此步重要,要不无法连接到虚拟机)。
2,虚拟机通过ifconfig 查看HostOnly网卡的ip,一般是192.168.56.X,然后就可以通过secureCRT 连接了。
备注:
1,确认你的虚拟机上的sshd已经安装并且打开。
2,宿主机可以通过 telnet 192.168.56.X(2步中的ip) 22 判断下是否可以连通
2012年7月6日星期五
2012年5月28日星期一
pycurl简介
- libcurl is a free and easy-to-use client-side URL transfer library, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, IMAP, SMTP, POP3 and RTSP. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos4), file transfer resume, http proxy tunneling and more!
- libcurl is highly portable, it builds and works identically on numerous platforms, including Solaris, NetBSD, FreeBSD, OpenBSD, Darwin, HPUX, IRIX, AIX, Tru64, Linux, UnixWare, HURD, Windows, Amiga, OS/2, BeOs, Mac OS X, Ultrix, QNX, OpenVMS, RISC OS, Novell NetWare, DOS and more...
- libcurl is free, thread-safe, IPv6 compatible, feature rich, well supported, fast, thoroughly documented and is already used by many known, big and successful companies and numerous applications.
一,简介与特性
PycURL是python的库,通过python封装了libcurl的调用,pycurl本身的文档不多,主要的说明可以参考libcurl的文档。
pycurl是一个成熟、非常快速并且支持多种特性。
Overview
源文档 <http://pycurl.sourceforge.net/>
二,与其他库对比
|
| Urllib2 | Urlgrabber | Pycurl |
| 简介 | 纯python程序,设计完善、灵活。 比较基础 | 纯python程序,基于urllib2,yum实现的一部分 | libcurl的封装,libcurl本身是c库,非常快,支持多种协议 |
| 优势 | 1)python自带,不依赖于外来库 2)纯python,简单易用,可自己在其基础上定制 | 1)比urllib2更友好的用户界面,封装了很多常用的基本功能 2)易于修改。 | 1)快 2)支持多种协议,类似SSL-ed FTP等 |
| 劣势 | 1)比pycurl慢 2)对低层协议的封装比较简陋,如果需要更多的功能,需要有较多的开发时间 | 1)比pycurl慢,某种程度上比urllib2略慢。不过封装的程序基本如此。 | 1),使用方式比较复杂。有比较陡的学习曲线。 调用方式C-style |
| 适用范围 | 只需要基础的功能,比如url访问等,或者需要再其基础上作定制封装。 | 需要较多的功能,灵活。 | 很快的速度要求,需要自己做调整,必要的协议支持。 |
http://urlgrabber.baseurl.org/comparison.html
三,使用方式
pycurl的文档的说明主要参考libcurl的文档说明,一些基本的用法,可以参考pycurl的test,example目录
http://pycurl.cvs.sourceforge.net/pycurl/pycurl/tests/
http://pycurl.cvs.sourceforge.net/pycurl/pycurl/examples/
基本的使用方式:
| 1 | #! /usr/bin/env python |
| 2 | # -*- coding: iso-8859-1 -*- |
| 3 | # vi:ts=4:et |
| 4 | # $Id: test_cb.py,v 1.14 2003/04/21 18:46:10 mfx Exp $ |
| 5 |
|
| 6 | import sys |
| 7 | import pycurl |
| 8 |
|
| 9 | ## Callback function invoked when body data is ready |
| 10 | def body(buf): |
| 11 | # Print body data to stdout |
| 12 | sys.stdout.write(buf) |
| 13 |
|
| 14 | ## Callback function invoked when header data is ready |
| 15 | def header(buf): |
| 16 | # Print header data to stderr |
| 17 | sys.stderr.write(buf) |
| 18 |
|
| 19 | c = pycurl.Curl() |
| 20 | c.setopt(pycurl.URL, 'http://www.python.org/') |
| 21 | c.setopt(pycurl.WRITEFUNCTION, body) |
| 22 | c.setopt(pycurl.HEADERFUNCTION, header) |
| 23 | c.setopt(pycurl.FOLLOWLOCATION, 1) |
| 24 | c.setopt(pycurl.MAXREDIRS, 5) |
| 25 | c.perform() |
| 26 | c.setopt(pycurl.URL, 'http://curl.haxx.se/') |
| 27 | c.perform() |
| 28 | c.close() |
源文档 <http://pycurl.cvs.sourceforge.net/viewvc/pycurl/pycurl/tests/test_cb.py?view=markup>
重要的是setopt方法,setopt方法对应的参数的说明见
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
基本的对应为
| Pycurl | Libcurl |
|
| FOLLOWLOCATION | CURLOPT_FOLLOWLOCATION |
|
| 诸如此类…… |
|
|
参考:
http://pycurl.sourceforge.net/
2012年4月7日星期六
jquery html() ie8下问题
$("#id").html(content)如果content内容不规范;
content内容不会被添加进id内
显示会有问题。