本文整理匯總了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)