本文整理汇总了Python中modules.libraries.client.request函数的典型用法代码示例。如果您正苦于以下问题:Python request函数的具体用法?Python request怎么用?Python request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resolve
def resolve(url):
try:
result = client.request(url)
post = {}
f = client.parseDOM(result, "Form", attrs = { "action": "" })
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post.update({'method_free': 'Watch Free!'})
post = urllib.urlencode(post)
result = client.request(url, post=post)
result = result.replace('\\/', '/').replace('\n', '').replace('\'', '"').replace(' ', '')
swfUrl = re.compile('\.embedSWF\("(.+?)"').findall(result)[0]
swfUrl = urlparse.urljoin(url, swfUrl)
streamer = re.compile('flashvars=.+?"file":"(.+?)"').findall(result)[0]
playpath = re.compile('flashvars=.+?p2pkey:"(.+?)"').findall(result)[0]
url = '%s playpath=%s conn=S:%s pageUrl=%s swfUrl=%s swfVfy=true timeout=20' % (streamer, playpath, playpath, url, swfUrl)
return url
except:
return
示例2: resolve
def resolve(url):
try:
result = client.request(url)
post = {}
f = client.parseDOM(result, "Form", attrs = { "action": "" })
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post.update({'method_free': 'Free Download'})
post = urllib.urlencode(post)
result = client.request(url, post=post)
post = {}
f = client.parseDOM(result, "Form", attrs = { "action": "" })
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post.update({'method_free': 'Free Download'})
try: post.update(captcha.request(result))
except: pass
post = urllib.urlencode(post)
result = client.request(url, post=post)
url = client.parseDOM(result, "a", ret="onClick")
url = [i for i in url if i.startswith('window.open')][0]
url = re.compile('[\'|\"](.+?)[\'|\"]').findall(url)[0]
return url
except:
return
示例3: resolve
def resolve(self, url):
try:
result = client.request(url)
result = result.decode('iso-8859-1').encode('utf-8')
url = client.parseDOM(result, "div", attrs = { "class": "player-embed" })[0]
url = client.parseDOM(url, "iframe", ret="src")[0]
if not 'auengine.com' in url:
url = client.parseDOM(result, "div", attrs = { "class": "generic-video-item" })
url = [i for i in url if 'auengine video' in i.lower()][0]
url = client.parseDOM(url, "a", ret="href")[0]
url = urlparse.urljoin(self.base_link, url)
result = client.request(url)
result = result.decode('iso-8859-1').encode('utf-8')
url = client.parseDOM(result, "div", attrs = { "class": "player-embed" })[0]
url = client.parseDOM(url, "iframe", ret="src")[0]
result = client.request(url)
url = re.compile("video_link *= *'(.+?)'").findall(result)[0]
url = urllib.unquote_plus(url)
return url
except:
return
示例4: resolve
def resolve(url):
try:
channel = urlparse.urlparse(url).path
channel = re.compile('/([\w]+)').findall(channel)[-1]
domain = urlparse.urlparse(url).netloc
pageUrl = urlparse.urljoin('http://%s' % domain, channel)
if 'instagib' in domain: playpath = 'instagib_%s' % channel
elif 'breakers' in domain: playpath = 'btv_%s' % channel
elif 'vapers' in domain: playpath = 'vtv_%s' % channel
else: playpath = 'live_%s' % channel
result = client.request(pageUrl, referer=pageUrl)
swfUrl = re.compile('"(/\d+/swf/[0-9A-Za-z]+\.swf)').findall(result)[0]
swfUrl = urlparse.urljoin(pageUrl, swfUrl)
infoUrl = 'http://mvn.vaughnsoft.net/video/edge/%s_%s' % (domain, channel)
result = client.request(infoUrl)
streamer = re.compile('(.+?);').findall(result)[0]
streamer = 'rtmp://%s/live' % streamer
app = re.compile('mvnkey-(.+)').findall(result)[0]
app = 'live?%s' % app
url = '%s app=%s playpath=%s pageUrl=%s swfUrl=%s swfVfy=true live=true timeout=20' % (streamer, app, playpath, pageUrl, swfUrl)
return url
except:
return
示例5: resolve
def resolve(url):
try:
if '/vod/' in url:
url = re.compile('/(\d+)').findall(url)[-1]
url = 'http://www.filmon.com/vod/info/%s' % url
elif '/tv/' in url:
url = url.replace('/tv/', '/channel/')
elif not '/channel/' in url:
raise Exception()
headers = {'X-Requested-With': 'XMLHttpRequest'}
result = client.request(url, headers=headers)
result = json.loads(result)
try:
result = result['streams']
except:
result = result['data']['streams']
result = [i[1] for i in result.iteritems()]
strm = [(i['url'], int(i['watch-timeout'])) for i in result]
strm = [i for i in strm if '.m3u8' in i[0]]
strm.sort()
strm = strm[-1][0]
url = client.request(strm).splitlines()
url = [i for i in url if '.m3u8' in i]
if len(url) == 0: return strm
url = urlparse.urljoin(strm, url[0])
return url
except:
return
示例6: resolve
def resolve(url):
try:
url = url.replace('/embed-', '/')
url = re.compile('//.+?/([\w]+)').findall(url)[0]
url = 'http://grifthost.com/embed-%s.html' % url
result = client.request(url)
try:
post = {}
f = client.parseDOM(result, "Form", attrs = { "method": "POST" })[0]
f = f.replace('"submit"', '"hidden"')
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post = urllib.urlencode(post)
result = client.request(url, post=post)
except:
pass
result = re.compile('(eval.*?\)\)\))').findall(result)[-1]
result = jsunpack.unpack(result)
url = client.parseDOM(result, "embed", ret="src")
url += re.compile("file *: *[\'|\"](.+?)[\'|\"]").findall(result)
url = [i for i in url if not i.endswith('.srt')]
url = 'http://' + url[0].split('://', 1)[-1]
return url
except:
return
示例7: resolve
def resolve(url):
try:
result = client.request(url)
post = {}
f = client.parseDOM(result, "Form", attrs = { "action": "" })[0]
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post.update({'method_free': ' '})
post = urllib.urlencode(post)
result = client.request(url, post=post)
post = {}
f = client.parseDOM(result, "Form", attrs = { "action": "" })[0]
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post.update({'method_free': ' '})
post.update(captcha.request(result))
post = urllib.urlencode(post)
result = client.request(url, post=post)
url = re.compile("var\s+download_url *= *'(.+?)'").findall(result)[0]
return url
except:
return
示例8: resolve
def resolve(url):
try:
url = re.compile('//.+?/([\w]+)').findall(url)[0]
url = 'http://www.movdivx.com/%s' % url
result = client.request(url)
post = {}
f = client.parseDOM(result, "Form", attrs = { "action": "" })[0]
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post.update({'method_free': 'Free Download'})
post = urllib.urlencode(post)
result = client.request(url, post=post)
result = re.compile('(eval.*?\)\)\))').findall(result)[-1]
result = jsunpack.unpack(result)
url = client.parseDOM(result, "embed", ret="src")
url += re.compile("file *: *[\'|\"](.+?)[\'|\"]").findall(result)
url = [i for i in url if not i.endswith('.srt')]
url = 'http://' + url[0].split('://', 1)[-1]
return url
except:
return
示例9: resolve
def resolve(url):
try:
user = control.setting('movreel_user')
password = control.setting('movreel_password')
login = 'http://movreel.com/login.html'
post = {'op': 'login', 'login': user, 'password': password, 'redirect': url}
post = urllib.urlencode(post)
result = client.request(url, close=False)
result += client.request(login, post=post, close=False)
post = {}
f = client.parseDOM(result, "Form", attrs = { "name": "F1" })[-1]
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post.update({'method_free': '', 'method_premium': ''})
post = urllib.urlencode(post)
request = urllib2.Request(url, post)
for i in range(0, 3):
try:
response = urllib2.urlopen(request, timeout=10)
result = response.read()
response.close()
url = re.compile('(<a .+?</a>)').findall(result)
url = [i for i in url if 'Download Link' in i][-1]
url = client.parseDOM(url, "a", ret="href")[0]
return url
except:
time.sleep(1)
except:
return
示例10: resolve
def resolve(url):
try:
result = client.request(url, mobile=True, close=False)
try:
post = {}
f = client.parseDOM(result, "Form", attrs = { "method": "POST" })[0]
f = f.replace('"submit"', '"hidden"')
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post = urllib.urlencode(post)
except:
post=None
for i in range(0, 10):
try:
result = client.request(url, post=post, mobile=True, close=False)
result = result.replace('\n','')
result = re.compile('sources *: *\[.+?\]').findall(result)[-1]
result = re.compile('file *: *"(http.+?)"').findall(result)
url = [i for i in result if '.m3u8' in i]
if len(url) > 0: return url[0]
url = [i for i in result if not '.m3u8' in i]
if len(url) > 0: return url[0]
except:
time.sleep(1)
except:
return
示例11: resolve
def resolve(url):
try:
url = re.compile('//.+?/([\w]+)').findall(url)[0]
url = 'http://180upload.com/embed-%s.html' % url
result = client.request(url)
post = {}
f = client.parseDOM(result, "form", attrs = { "id": "captchaForm" })[0]
k = client.parseDOM(f, "input", ret="name", attrs = { "type": "hidden" })
for i in k: post.update({i: client.parseDOM(f, "input", ret="value", attrs = { "name": i })[0]})
post = urllib.urlencode(post)
result = client.request(url, post=post)
result = re.compile('(eval.*?\)\)\))').findall(result)[-1]
result = jsunpack.unpack(result)
url = client.parseDOM(result, "embed", ret="src")
url += re.compile("'file' *, *'(.+?)'").findall(result)
url = [i for i in url if not i.endswith('.srt')]
url = 'http://' + url[0].split('://', 1)[-1]
return url
except:
return
示例12: resolve
def resolve(self, url):
try:
result = client.request(url)
if not "my_video" in result:
cookie = client.request(self.sign_link, post=self.key_link, output="cookie")
result = client.request(url, cookie=cookie)
url = None
try:
url = client.parseDOM(result, "source", ret="src", attrs={"type": "video/webm"})[0]
except:
pass
try:
url = client.parseDOM(result, "source", ret="src", attrs={"type": "video/mp4"})[0]
except:
pass
if url == None:
return
url = urlparse.urljoin(self.base_link, url)
url = "%s|Cookie=%s" % (url, urllib.quote_plus("video=true"))
return url
except:
return
示例13: resolve
def resolve(self, url):
try:
query = urlparse.urljoin(self.base_link, self.login_link)
post = urllib.urlencode({'login': self.user, 'pwd': self.password})
cookie = client.request(query, post=post, output='cookie')
result = client.request(url, cookie=cookie)
url = client.parseDOM(result, "location")[0]
return url
except:
return
示例14: resolve
def resolve(url):
try:
result = client.request(url, close=False)
f = client.parseDOM(result, "a", ret="href", attrs = { "id": "go-next" })[0]
f = urlparse.urljoin(url, f)
result = client.request(f)
url = re.compile("var\s+lnk\d* *= *'(http.+?)'").findall(result)[0]
return url
except:
return
示例15: resolve
def resolve(self, url):
try:
if urlparse.urlparse(url).netloc in self.base_link:
return self.__resolve(client.request(url))
if url.startswith('stack://'): return url
url = client.request(url, output='geturl')
if 'requiressl=yes' in url: url = url.replace('http://', 'https://')
else: url = url.replace('https://', 'http://')
return url
except:
return