本文整理汇总了Python中urlgrabber.grabber.URLGrabber.urlopen方法的典型用法代码示例。如果您正苦于以下问题:Python URLGrabber.urlopen方法的具体用法?Python URLGrabber.urlopen怎么用?Python URLGrabber.urlopen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urlgrabber.grabber.URLGrabber
的用法示例。
在下文中一共展示了URLGrabber.urlopen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProxyHTTPAuthTests
# 需要导入模块: from urlgrabber.grabber import URLGrabber [as 别名]
# 或者: from urlgrabber.grabber.URLGrabber import urlopen [as 别名]
class ProxyHTTPAuthTests(BaseProxyTests):
def setUp(self):
self.url = ref_http
if not self.have_proxy():
self.skip()
self.g = URLGrabber()
def test_good_password(self):
self.g.urlopen(self.url, proxies=self.good_proxies)
def test_bad_password(self):
self.assertRaises(URLGrabError, self.g.urlopen,
self.url, proxies=self.bad_proxies)
示例2: urlopen
# 需要导入模块: from urlgrabber.grabber import URLGrabber [as 别名]
# 或者: from urlgrabber.grabber.URLGrabber import urlopen [as 别名]
def urlopen(self, filename, *args, **kwargs):
self.check_offline_mode()
# This is for older versions of urlgrabber which are packaged in Debian
# and Ubuntu and cannot handle filenames as a normal Python string but need
# a unicode string.
return URLGrabber.urlopen(self, filename.encode("utf-8"), *args, **kwargs)