本文整理汇总了Python中test.helper.FakeYDL.urlopen方法的典型用法代码示例。如果您正苦于以下问题:Python FakeYDL.urlopen方法的具体用法?Python FakeYDL.urlopen怎么用?Python FakeYDL.urlopen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.helper.FakeYDL
的用法示例。
在下文中一共展示了FakeYDL.urlopen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_ip
# 需要导入模块: from test.helper import FakeYDL [as 别名]
# 或者: from test.helper.FakeYDL import urlopen [as 别名]
def _get_ip(self, protocol):
if self._SKIP_SOCKS_TEST:
return '127.0.0.1'
ydl = FakeYDL({
'proxy': '%s://127.0.0.1:%d' % (protocol, self.port),
})
return ydl.urlopen('http://yt-dl.org/ip').read().decode('utf-8')
示例2: test_secondary_proxy_https
# 需要导入模块: from test.helper import FakeYDL [as 别名]
# 或者: from test.helper.FakeYDL import urlopen [as 别名]
def test_secondary_proxy_https(self):
params = self._check_params(['secondary_proxy', 'secondary_server_ip'])
if params is None:
return
ydl = FakeYDL()
req = compat_urllib_request.Request('https://yt-dl.org/ip')
req.add_header('Ytdl-request-proxy', params['secondary_proxy'])
self.assertEqual(
ydl.urlopen(req).read().decode('utf-8'),
params['secondary_server_ip'])
示例3: test_proxy_https
# 需要导入模块: from test.helper import FakeYDL [as 别名]
# 或者: from test.helper.FakeYDL import urlopen [as 别名]
def test_proxy_https(self):
params = self._check_params(['primary_proxy', 'primary_server_ip'])
if params is None:
return
ydl = FakeYDL({
'proxy': params['primary_proxy']
})
self.assertEqual(
ydl.urlopen('https://yt-dl.org/ip').read().decode('utf-8'),
params['primary_server_ip'])
示例4: BaseTestSubtitles
# 需要导入模块: from test.helper import FakeYDL [as 别名]
# 或者: from test.helper.FakeYDL import urlopen [as 别名]
class BaseTestSubtitles(unittest.TestCase):
url = None
IE = None
def setUp(self):
self.DL = FakeYDL()
self.ie = self.IE()
self.DL.add_info_extractor(self.ie)
def getInfoDict(self):
info_dict = self.DL.extract_info(self.url, download=False)
return info_dict
def getSubtitles(self):
info_dict = self.getInfoDict()
subtitles = info_dict['requested_subtitles']
if not subtitles:
return subtitles
for sub_info in subtitles.values():
if sub_info.get('data') is None:
uf = self.DL.urlopen(sub_info['url'])
sub_info['data'] = uf.read().decode('utf-8')
return dict((l, sub_info['data']) for l, sub_info in subtitles.items())