python urllib的使用,Python urllib库使用

In [2]: import urllib

In [3]: s = urllib.urlopen("http://www.imekaku.com")

In [4]: help(s)

Help on instance of addinfourl in module urllib:

class addinfourl(addbase)

| class to add info() and geturl() methods to an open file.

|

| Methods defined here:

|

| __init__(self, fp, headers, url, code=None)

|

| getcode(self)

|

| geturl(self)

|

| info(self)

|

| ----------------------------------------------------------------------

| Methods inherited from addbase:

|

| __repr__(self)

|

| close(self)

In [5]: msg = s.info()

# msg是一个HTTPMessage对象

In [6]: help(msg)

Help on instance of HTTPMessage in module httplib:

class HTTPMessage(mimetools.Message)

| Method resolution order:

| HTTPMessage

| mimetools.Message

| rfc822.Message

|

| Methods defined here:

|

| addcontinue(self, key, more)

| Add more field data from a continuation line.

|

| addheader(self, key, value)

| Add header for field key handling repeats.

|

| readheaders(self)

| Read header lines.

|

| Read header lines up to the entirely blank line that terminates them.

| The (normally blank) line that ends the headers is skipped, but not

| included in the returned list. If a non-header line ends the headers,

| (which is an error), an attempt is made to backspace over it; it is

| never included in the returned list.

|

| The variable self.status is set to the empty string if all went well,

| otherwise it is an error message. The variable self.headers is a

| completely uninterpreted list of lines contained in the header (so

| printing them will reproduce the header exactly as it appears in the

| file).

:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值