Using the Curl library Pycurl examples and parameters in detail

Source: Internet
Author: User
Tags response code
Pycurl is a powerful Python URL library, written in C, fast, faster than Urllib and Httplib.

Today, let's take a look at the usage and parameters of Pycurl

Common methods:

Pycurl. Curl () #创建一个pycurl对象的方法

Pycurl. Curl (). setopt (Pycurl. URL, http://www.pythontab.com) #设置要访问的URL

Pycurl. Curl (). setopt (Pycurl. Maxredirs, 5) #设置最大重定向次数

Pycurl. Curl (). setopt (Pycurl. ConnectTimeout, 60)

Pycurl. Curl (). setopt (Pycurl. TIMEOUT, #连接超时设置

Pycurl. Curl (). setopt (Pycurl. UserAgent, "mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1,. NET CLR 1.1.4322) #模拟浏览器

Pycurl. Curl (). Perform () #服务器端返回的信息

Pycurl. Curl (). GetInfo (Pycurl. Http_code) #查看HTTP的状态 similar to the status attribute in Urllib

Pycurl. Namelookup_time Domain Name resolution time

Pycurl. Connect_time Remote Server Connection time

Pycurl. Pretransfer_time the time after the connection is over to the start of the transfer

Pycurl. Starttransfer_time the time that the first byte was received

Pycurl. Total_time the total time of the previous request

Pycurl. Redirect_time If there is a turn, the time spent

Pycurl. Effective_url

Pycurl. Http_code HTTP Response Code

Pycurl. Number of Redirect_count redirects

Pycurl. Size_upload size of uploaded data

Pycurl. Size_download the size of the downloaded data

Pycurl. Speed_upload upload Speed

Pycurl. Header_size Head Size

Pycurl. Request_size Request Size

Pycurl. Content_length_download Download Content Length

Pycurl. Content_length_upload Upload Content Length

Pycurl. Types of Content_Type Content

Pycurl. Response_code Response Code

Pycurl. Speed_download Download speed

Pycurl. Ssl_verifyresult

Time information for the Pycurl.info_filetime file

Pycurl. Http_connectcode HTTP Connection Code

Pycurl. Httpauth_avail

Pycurl. Proxyauth_avail

Pycurl. Os_errno

Pycurl. Num_connects

Pycurl. Ssl_engines

Pycurl.info_cookielist

Pycurl. Lastsocket

Pycurl. Ftp_entry_path

Instance:

Import Stringioimport pycurl c = pycurl. Curl () str = Stringio.stringio () c.setopt (Pycurl. URL, "http://www.pythontab.com") c.setopt (Pycurl. Writefunction, Str.write) c.setopt (Pycurl. Followlocation, 1) c.perform () print c.getinfo (Pycurl. Effective_url)

A friend familiar with PHP may have discovered that the Curl Library is very similar to PHP's curl.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.