本文整理汇总了Python中urllib.FancyURLopener.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python FancyURLopener.__init__方法的具体用法?Python FancyURLopener.__init__怎么用?Python FancyURLopener.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib.FancyURLopener
的用法示例。
在下文中一共展示了FancyURLopener.__init__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self):
try:
context = ssl._create_unverified_context()
except AttributeError:
context = None
FancyURLopener.__init__(self, context=context)
示例2: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self._last_url = u''
FancyURLopener.__init__(self, *args, **kwargs)
# Headers to add to every request.
# XXX: IMDb's web server doesn't like urllib-based programs,
# so lets fake to be Mozilla.
# Wow! I'm shocked by my total lack of ethic! <g>
self.set_header('User-agent', 'Mozilla/5.0')
# XXX: This class is used also to perform "Exact Primary
# [Title|Name]" searches, and so by default the cookie is set.
c_header = 'id=%s; uu=%s' % (_cookie_id, _cookie_uu)
self.set_header('Cookie', c_header)
示例3: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self, ftpproxy=''):
"""RebaseUpdate([ftpproxy]]) -> new RebaseUpdate instance.
if ftpproxy is not given RebaseUpdate uses the corresponding
variable from RanaConfig.
ftpproxy is the proxy to use if any.
"""
proxy = {'ftp': ftpproxy or ftp_proxy}
if not Rebase_name:
raise FtpNameError('Rebase')
if not proxy['ftp']:
proxy = {}
FancyURLopener.__init__(self, proxy)
示例4: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self._last_url = u""
FancyURLopener.__init__(self, *args, **kwargs)
# Headers to add to every request.
# XXX: IMDb's web server doesn't like urllib-based programs,
# so lets fake to be Mozilla.
# Wow! I'm shocked by my total lack of ethic! <g>
for header in ("User-Agent", "User-agent", "user-agent"):
self.del_header(header)
self.set_header("User-Agent", "Mozilla/5.0")
self.set_header("Accept-Language", "en-us,en;q=0.5")
# XXX: This class is used also to perform "Exact Primary
# [Title|Name]" searches, and so by default the cookie is set.
c_header = "uu=%s; id=%s" % (_cookie_uu, _cookie_id)
self.set_header("Cookie", c_header)
示例5: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self, *args, **kwargs):
try: self.username = kwargs['username']
except KeyError: self.username = None
try: self.password = kwargs['password']
except KeyError: self.password = None
# once urllib uses new style classes, or in python 3.0+, use:
# super(FancyURLopenerMod, self).__init__(*args, **kwargs)
# till then this will work, but not in python 3.0+:
FancyURLopener.__init__(self, *args, **kwargs)
# only try opening the account once
#self.authtries = 0
#self.maxauthtries = 3
self.flag = False
示例6: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self, e_mail="", ftpproxy=""):
"""RebaseUpdate([e_mail[, ftpproxy]]) -> new RebaseUpdate instance.
if e_mail and ftpproxy are not given RebaseUpdate uses the corresponding
variable from RanaConfig.
e_mail is the password for the anonymous ftp connection to Rebase.
ftpproxy is the proxy to use if any."""
proxy = {"ftp": ftpproxy or ftp_proxy}
global Rebase_password
Rebase_password = e_mail or Rebase_password
if not Rebase_password:
raise FtpPasswordError("Rebase")
if not Rebase_name:
raise FtpNameError("Rebase")
FancyURLopener.__init__(self, proxy)
示例7: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self, username=None, passwd=None, *args, **kw):
FancyURLopener.__init__( self, *args, **kw)
self.username = username
self.passwd = passwd
示例8: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self, user, passwd):
self._user = user
self._passwd = passwd
self._promptcalled = False
FancyURLopener.__init__(self)
示例9: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self):
FancyURLopener.__init__(self)
示例10: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self, user_agent):
self.version = user_agent
FancyURLopener.__init__(self)
示例11: __init__
# 需要导入模块: from urllib import FancyURLopener [as 别名]
# 或者: from urllib.FancyURLopener import __init__ [as 别名]
def __init__(self):
FancyURLopener.__init__(self, proxies={})