首页IT科技2060和3050显卡哪个好(20.6. urllib2 — extensible library for opening URLs — Python v2.7.3 documentation)

2060和3050显卡哪个好(20.6. urllib2 — extensible library for opening URLs — Python v2.7.3 documentation)

时间2025-05-02 17:43:33分类IT科技浏览4280
导读:class urllib2.Request(url[, data][, headers][, origin_req_host][, unverifiable] ¶ This class is an abstraction of a URL request....

class urllib2.Request(url[, data][, headers][, origin_req_host][, unverifiable])¶

This class is an abstraction of a URL request.

url should be a string containing a valid URL.

data may be a string specifying additional data to send to the server, or

None

if no such data is needed. Currently HTTP requests are the only ones

that use data; the HTTP request will be a POST instead of a GET when the

data parameter is provided. data should be a buffer in the standard

application/x-www-form-urlencoded format. The

urllib.urlencode()

function takes a mapping or sequence of 2-tuples and

returns a string in this format.

headers should be a dictionary, and will be treated as if add_header()

was called with each key and value as arguments. This is often used to “spoof            ”

the User-Agent

header, which is used by a browser to identify itself –

some HTTP servers only allow requests coming from common browsers as opposed

to scripts. For example, Mozilla Firefox may identify itself as "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11", while urllib2

‘s

default user agent string is "Python-urllib/2.6" (on Python 2.6).

The final two arguments are only of interest for correct handling of third-party

HTTP cookies:

origin_req_host should be the request-host of the origin transaction, as

defined by RFC 2965. It defaults to cookielib.request_host(self)

. This

is the host name or IP address of the original request that was initiated by the

user. For example, if the request is for an image in an HTML document, this

should be the request-host of the request for the page containing the image.

unverifiable should indicate whether the request is unverifiable, as defined

by RFC 2965. It defaults to False. An unverifiable request is one whose URL

the user did not have the option to approve. For example, if the request is for

an image in an HTML document, and the user had no option to approve the

automatic fetching of the image, this should be true. class urllib2.OpenerDirector¶

The OpenerDirector class opens URLs via BaseHandler

s chained

together. It manages the chaining of handlers, and recovery from errors. class urllib2.BaseHandler¶

This is the base class for all registered handlers — and handles only the

simple mechanics of registration. class urllib2.HTTPDefaultErrorHandler¶

A class which defines a default handler for HTTP error responses; all responses

are turned into HTTPError exceptions. class urllib2.HTTPRedirectHandler¶

A class to handle redirections.

class urllib2.HTTPCookieProcessor([cookiejar]

A class to handle HTTP Cookies.

class urllib2.ProxyHandler([proxies]

Cause requests to go through a proxy. If proxies is given, it must be a

dictionary mapping protocol names to URLs of proxies. The default is to read

the list of proxies from the environment variables

<protocol>_proxy

. If no proxy environment variables are set, in a

Windows environment, proxy settings are obtained from the registry’s

Internet Settings section and in a Mac OS X environment, proxy information

is retrieved from the OS X System Configuration Framework.

To disable autodetected proxy pass an empty dictionary.

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
python字符串菜鸟教程(09python字符串) ieeextreme2021(2022 IEEE 编程语言榜单发布!Python 又双叒叕霸榜了,学 SQL 工作更吃香!)