Python论坛  - 讨论区

标题:[python-chinese] 如何使用urllib2?

2007年01月29日 星期一 22:15

zhbguan zhbguan在lemote.com
星期一 一月 29 22:15:27 HKT 2007

ÎÒÔÚpythonµÄ½»»¥Ê½ÊäÈëÖУ¬ÊäÈëһϴúÂë
>>>import urllib2
>>>f = urllib2.urlopen('http://www.lemote.com')
>>>print f.read(100)

ÒÔÉÏ¿ÉÒÔÕý³£ÔËÐС£

µ«ÊÇ£¬½«Õ⼸ÐдúÂëдÈëµ½Ò»¸öÎļþÖУ¬ÄÇôÔËÐÐÕâ¸öÎļþ£¬¾Í»á³öÏÖÎÊÌ⣺

Traceback (most recent call last):
  File "./log-bbs.py", line 6, in ?
    f = urllib2.urlopen('http//www.lemote.com/')
  File "/usr/lib/python2.4/urllib2.py", line 130, in urlopen
    return _opener.open(url, data)
  File "/usr/lib/python2.4/urllib2.py", line 350, in open
    protocol = req.get_type()
  File "/usr/lib/python2.4/urllib2.py", line 233, in get_type
    raise ValueError, "unknown url type: %s" % self.__original
ValueError: unknown url type: http//www.lemote.com/

Çë½ÌÔõô»ØÊ°¡£¿





zhbguan
2007-01-29
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070129/d1a9df68/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年01月29日 星期一 22:24

WiseNeuron wiseneuron在126.com
星期一 一月 29 22:24:35 HKT 2007

ÎÒÊÔÑéÁËÏ£¬Ã»ÎÊÌâ¡£ÊÇÄãÕâÀï  f = urllib2.urlopen('http//www.lemote.com/')
ÉÙÁ˸ö":",½«f = urllib2.urlopen('http//www.lemote.com/') ¸ÄΪ f = urllib2.urlopen('http://www.lemote.com/')


  ----- Original Message ----- 
  From: zhbguan 
  To: python-chinese在lists.python.cn 
  Sent: Monday, January 29, 2007 10:15 PM
  Subject: [python-chinese] ÈçºÎʹÓÃurllib2?


  ÎÒÔÚpythonµÄ½»»¥Ê½ÊäÈëÖУ¬ÊäÈëһϴúÂë
  >>>import urllib2
  >>>f = urllib2.urlopen('http://www.lemote.com')
  >>>print f.read(100)

  ÒÔÉÏ¿ÉÒÔÕý³£ÔËÐС£

  µ«ÊÇ£¬½«Õ⼸ÐдúÂëдÈëµ½Ò»¸öÎļþÖУ¬ÄÇôÔËÐÐÕâ¸öÎļþ£¬¾Í»á³öÏÖÎÊÌ⣺

  Traceback (most recent call last):
    File "./log-bbs.py", line 6, in ?
      f = urllib2.urlopen('http//www.lemote.com/')
    File "/usr/lib/python2.4/urllib2.py", line 130, in urlopen
      return _opener.open(url, data)
    File "/usr/lib/python2.4/urllib2.py", line 350, in open
      protocol = req.get_type()
    File "/usr/lib/python2.4/urllib2.py", line 233, in get_type
      raise ValueError, "unknown url type: %s" % self.__original
  ValueError: unknown url type: http//www.lemote.com/

  Çë½ÌÔõô»ØÊ°¡£¿



------------------------------------------------------------------------------

  zhbguan
  2007-01-29


------------------------------------------------------------------------------


  _______________________________________________
  python-chinese
  Post: send python-chinese在lists.python.cn
  Subscribe: send subscribe to python-chinese-request在lists.python.cn
  Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
  Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070129/9d902ad2/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号