当前位置: 首页>>代码示例>>Python>>正文


Python urlfetch.get函数代码示例

本文整理汇总了Python中urlfetch.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getHaivn

def getHaivn(url):
	headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0',
			'Referer'  : url
		}
	response = urlfetch.get(url, headers=headers)
	if not response:
		notify(u'Trang nguồn có lỗi. Thông báo cho dev.'.encode("utf-8"))

	if 'youtube-player' in response.body:
		
		matches = re.search(r"iframe allowfullscreen=\"true\" src=\"(.+?)\?", response.body)
		
		video_url = matches.group(1)
		matches = re.search(r"embed\/(.+)", video_url)
		youtube_id = matches.group(1)
		video_url = "plugin://plugin.video.youtube/?path=/root/video&action=play_video&videoid=" + youtube_id
		
	else:
		regex = r'script type=\"text\/javascript\" src=\"(.+?mecloud-player)\"'
		matches = re.search(regex, response.body)
		if not matches:
			return ''
		url_player = matches.group(1)
		
		response = urlfetch.get(url_player, headers=headers)
		regex = r"\"video\":(\[.+?\])"
		matches = re.search(regex, response.body)
		video_url = matches.group(1)
		t = video_url.count('url')
		data = json.loads(video_url)
		video_url = data[t-1]['url']
		video_url = 'http:'+video_url
	
	return video_url
	xbmc.log(video_url)
开发者ID:vphuc81,项目名称:MyRepository,代码行数:35,代码来源:getlink.py

示例2: getPhimMoi

def getPhimMoi(url):
	headers = { 'User_Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0',
				'Host'				: 'www.phimmoi.net',
				'Referer'			: url
				}
	T2="U2FsdGVkX1+J5yRXU1goqexulsqcAaICSdXjSrml+FFQiYusRAwciVrwAIW86pvrU2RGQmSb9YL/8xMaOnWGbA"		
	response = urlfetch.get(url, headers=headers)
	regex = r"(;eval.+)<\/script>"
	matches = re.search(regex, response.body)
	payload = matches.group(1)
	payload = urllib.quote(payload)
	payload = "data="+payload
	headers = {
		'content-type': "application/x-www-form-urlencoded",
		'cache-control': "no-cache"
		}
	response = urlfetch.post(vmf.gibberishAES(T2, 'vmf'), data=payload, headers=headers)
	response = urlfetch.get(response.body)
	regex = r"var _responseJson='(.+)';"
	matches = re.search(regex, response.body)
	json_data = matches.group(1)
	json_data = json.loads(json_data)
	backup_order = json_data['backupOrder']
	t = len(json_data['medias'])
	video_url = json_data['medias'][(t-1)]['url']
	return video_url
	'''
开发者ID:vphuc81,项目名称:MyRepository,代码行数:27,代码来源:getlink.py

示例3: getVtv

def getVtv(url)	:
	response = urlfetch.get(url)
	matches = re.search(r"src=\"(.+play.+?)\"", response.body)
	play_url = matches.group(1)
	headers = {'Host': 'play.sohatv.vn', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0', 'Referer': url}
	response = urlfetch.get(play_url, headers=headers)
	matches = re.search(r"status-code=200 src=\"(.+?)\"", response.body)
	url_play = matches.group(1)
	matches = re.search(r"live=(.+?m3u8)", url_play)
	m3u8 = matches.group(1)
	m3u8 = 'http:'+urllib.unquote_plus(m3u8)
	split_list = m3u8.split('/', 9)
	remove = split_list[8]
	vtvvn_option = 'true'
	if 'vtv5-tay-nam-bo' not in url:
		matches = re.search(r"==(.+?)\.", remove)
		remove = matches.group(1)
		if vtvvn_option == 'false':
			m3u8 = m3u8.replace(remove, '_m')
		if vtvvn_option == 'true':
			m3u8 = m3u8.replace(remove, '')
	else:
		print('Kenh vtv5 nam bo')
		if vtvvn_option == 'false':
			m3u8 = m3u8.replace(remove, 'dnR2NWtt_m.m3u8')
		if vtvvn_option == 'true':
			m3u8 = m3u8.replace(remove, 'dnR2NWtt.m3u8')
	return m3u8
开发者ID:vphuc81,项目名称:MyRepository,代码行数:28,代码来源:getlink.py

示例4: resolve_url

def resolve_url(url):
	if freeAccount == 'true':
		response = urlfetch.fetch("http://feed.hdrepo.com/fshare.php")
		if response.status == 200:
			headers['Cookie'] = response.content
		else:
			xbmc.executebuiltin((u'XBMC.Notification("%s", "%s", %s)' % ('Login', 'Server only accepts 1 request/minute', '5000')).encode("utf-8"))	 
			return
	else:
		headers['Cookie'] = doLogin()

	response = urlfetch.get(url,headers=headers, follow_redirects=False)
	if response.status==302 and response.headers['location'].find('logout.php')<0:
		url=response.headers['location']
		# logout
		if freeAccount == 'true':
			cookie = Cookie.SimpleCookie()
			cookie.load(response.headers.get('set-cookie', ''))
			headers['Cookie'] = _makeCookieHeader(cookie)
			urlfetch.get("https://www.fshare.vn/logout.php",headers=headers, follow_redirects=False)
	else:
		if response.status==200:
			soup = BeautifulSoup(str(response.content), convertEntities=BeautifulSoup.HTML_ENTITIES)		
			item = soup.find('form', {'name' : 'frm_download'})
			if item:
				url = item['action']
		else:
			xbmc.executebuiltin((u'XBMC.Notification("%s", "%s", %s)' % ('Login', 'Login failed. You must input correct FShare username/pass in Add-on settings', '5000')).encode("utf-8"))	 
			return
	
	item = xbmcgui.ListItem(path=url)
	xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
开发者ID:minhvtran2005,项目名称:xbmc-plugins,代码行数:32,代码来源:default.py

示例5: test_compressed_streaming

    def test_compressed_streaming(self):
        sina = urlfetch.b('sina')

        with tempfile.TemporaryFile() as f:
            with urlfetch.get('http://news.sina.com.cn/') as r:
                for chunk in r:
                    f.write(chunk)
            f.seek(0)
            html = f.read()
            self.assertTrue(sina in html)

        with tempfile.TemporaryFile() as f:
            with urlfetch.get('http://news.sina.com.cn/', headers={'Accept-Encoding': 'deflate'}) as r:
                for chunk in r:
                    f.write(chunk)
            f.seek(0)
            html = f.read()
            self.assertTrue(sina in html)

        with tempfile.TemporaryFile() as f:
            with urlfetch.get('http://news.sina.com.cn/', headers={'Accept-Encoding': 'gzip'}) as r:
                for chunk in r:
                    f.write(chunk)
            f.seek(0)
            html = f.read()
            self.assertTrue(sina in html)

        with tempfile.TemporaryFile() as f:
            with urlfetch.get('http://news.sina.com.cn/', headers={'Accept-Encoding': '*'}) as r:
                for chunk in r:
                    f.write(chunk)
            f.seek(0)
            html = f.read()
            self.assertTrue(sina in html)
开发者ID:satels,项目名称:urlfetch,代码行数:34,代码来源:test_get.py

示例6: test_links

    def test_links(self):
        r = urlfetch.get(testlib.url('/links/0'))
        self.assertTrue(r.links)
        self.assertTrue(isinstance(r.links, list))
        self.assertTrue(len(r.links) == 1)

        r = urlfetch.get(testlib.url('/links/1'))
        self.assertTrue(r.links)
        self.assertTrue(isinstance(r.links, list))
        self.assertTrue(len(r.links) == 2)

        r = urlfetch.get(testlib.url('/links/2'))
        self.assertTrue(r.links)
        self.assertTrue(isinstance(r.links, list))
        self.assertTrue(len(r.links) == 4)

        r = urlfetch.get(testlib.url('/links/3'))
        self.assertTrue(r.links)
        self.assertTrue(isinstance(r.links, list))
        self.assertTrue(len(r.links) == 2)

        r = urlfetch.get(testlib.url('/links/none'))
        self.assertTrue(r.links)
        self.assertTrue(isinstance(r.links, list))
        self.assertTrue(len(r.links) == 1)
开发者ID:ifduyue,项目名称:urlfetch,代码行数:25,代码来源:test_get.py

示例7: test_get_via_proxy

    def test_get_via_proxy(self):
        proxy = testlib.test_server_host[:-1]
        resp = urlfetch.get("http://www.example.com", proxies={"http": proxy})
        self.assertEqual(resp.status, 200)

        proxy = proxy.split("://", 1)[1]
        resp = urlfetch.get("http://www.example.com", proxies={"http": proxy})
        self.assertEqual(resp.status, 200)
开发者ID:ownport,项目名称:urlfetch,代码行数:8,代码来源:test_proxy.py

示例8: download_sub

def download_sub(subtitle):
	xbmc_temp = xbmc.translatePath('special://temp')
	tempdir = os.path.join(xbmc_temp, 'phudeVMF')
	if 'subscene.com' in subtitle:
		response = urlfetch.get(subtitle)
		sub = re.search(r'href=\"(/subtitle/download?.*?)\"', response.body)
		sub = sub.group(1)
		subpath = "https://subscene.com" + sub
	if 'phudeviet.org' in subtitle:
		f = urlfetch.get(subtitle)
		match = re.search(r"(http://phudeviet.org/download/.+?html)", f.body)
		subpath = match.group(1)
		f = urlfetch.get(subpath)
		subpath = f.getheader('location')
		
	vDialog.create('Vietmediaf','Bắt đầu tải phụ đề xin vui lòng đợi trong giây lát.','Downloading...')
	if not os.path.exists(tempdir):
		try:
			xbmcvfs.mkdirs(tempdir)
			time.sleep(20)
		except:pass
	else:
		for root, dirs, files in os.walk(tempdir, topdown=False):
			for name in files:
				try:os.remove(os.path.join(root, name))
				except:pass
			for name in dirs:
				try:os.rmdir(os.path.join(root, name))
				except:pass
	
	useragent = ("User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0")
	headers = {'User-Agent': useragent, 'Referer': subtitle}
	tmp_file = os.path.join(tempdir, "phude.zip")
	
	try:
		if os.path.exists(tmp_file):
			os.remove(tmp_file)
		request = urllib2.Request(subpath, '', headers)
		response = urllib2.urlopen(request)
		file_handle = xbmcvfs.File(tmp_file, "wb")
		file_handle.write(response.read())
		xbmc.sleep(500)
		file_handle.close()
		xbmc.executebuiltin('XBMC.Extract("%s","%s")' % (tmp_file, tempdir))
		
	except:
		notify('Không tải được phụ đề')
		pass
	vDialog.close()
	exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass"]
	sub_temp = os.path.join(tempdir, "sub.file")
	for file in xbmcvfs.listdir(tempdir)[1]:
		if os.path.splitext(file)[1] in exts:
			sub_file = os.path.join(tempdir, file)
			xbmcvfs.rename(sub_file, sub_temp)
			return sub_temp
开发者ID:vphuc81,项目名称:MyRepository,代码行数:56,代码来源:default.py

示例9: get_htvplus

def get_htvplus(url):
	if len(USER_VIP_CODE) > 0:
		try:
			f='U2FsdGVkX1+RQXkDAFegicGii3RLBVGrsbMVRV+kHpUpTExURcDQLDLLDkxsGOTf'
			notify(u'VMF Getlink system'.encode("utf-8"))
			response = fetch_data(VIETMEDIA_HOST + vmf.gibberishAES(f, 'vmf'))
			json_data = json.loads(response.body)
			t =json_data['username'].decode("base64")
			headers = { 
					'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
					'Referer'			: url,
					'Cookie'		: t
					}
			response = urlfetch.get(url, headers=headers)
			
			regex = r"iosUrl = \"(.+?)\""	
			matches = re.search(regex, response.body)
			video_url = matches.group(1)
			get_url = 'http://hplus.com.vn/content/getlinkvideo/'
			headers = { 
					'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
					'Referer'			: url,
					'Cookie'		: t			
					}
			data = {'url': video_url, 'type': '1', 'is_mobile': '0'}
			response = urlfetch.post(get_url, headers=headers, data=data)
			video_url = response.body.encode("utf-8")
			refer = "|User-Agent=Mozilla%2F5.0%20%28Windows%20NT%2010.0%3B%20Win64%3B%20x64%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F58.0.3029.110%20Safari%2F537.36&Referer=http%3A%2F%2Fhplus.com.vn%2F"
			return (video_url + refer)
		except Exception as e:
			notify('Khong lay duoc link')
			pass
	else:
		headers = { 
					'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
					'Referer'			: url,
					'Cookie'		: t
					}
		response = urlfetch.get(url, headers=headers)
		t = response.cookiestring;
		regex = r"iosUrl = \"(.+?)\""	
		matches = re.search(regex, response.body)
		video_url = matches.group(1)
		get_url = 'http://hplus.com.vn/content/getlinkvideo/'
		headers = { 
				'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
				'Referer'			: url,
				'Cookie'		: t			
				}
		data = {'url': video_url, 'type': '1', 'is_mobile': '0'}
		response = urlfetch.post(get_url, headers=headers, data=data)
		video_url = response.body.encode("utf-8")
		refer = "|User-Agent=Mozilla%2F5.0%20%28Windows%20NT%2010.0%3B%20Win64%3B%20x64%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F58.0.3029.110%20Safari%2F537.36&Referer=http%3A%2F%2Fhplus.com.vn%2F"
		return (video_url + refer)
开发者ID:vphuc81,项目名称:MyRepository,代码行数:54,代码来源:getlink.py

示例10: search_movie

def search_movie(item):
	title=item['title'];year=item['year'];filename=item['filename'];mansearchstr=item['mansearchstr']
	if mansearchstr:title=mansearchstr;mess('Manual search for string')
	else:title=re.sub('&#.* ','',title.replace("&","and")).strip()
	subspage_url=find_movie(title, year);subtitles=[];subs=[]
	pattern='<a href="(/subtitles/.+?)">\s+<span class=".+?">\s*(.+?)\s+</span>\s+<span>\s+(.+?)\s+</span>'
	if subspage_url:
		url=subscene+subspage_url
		subs=re.findall(pattern,urlfetch.get(url=url,headers={'Cookie':'LanguageFilter=13,45'}).body)
	if mansearchstr:
		url=subscene+'/subtitles/release?q='+urllib.quote_plus(title)+'&r=true'
		subs+=re.findall(pattern,urlfetch.get(url=url,headers={'Cookie':'LanguageFilter=13,45'}).body)
	phudeviet_url = find_phudeviet(title, year)
	if not phudeviet_url:
		phudeviet_url = google_find_phudeviet(title,year)
	if phudeviet_url:
		pattern_pdv='<td class="td4".+"(.+png)">.+\s+<td class="td1".+href="(.+?)">(.+?)<.+td>'
		for lang,href,fn in re.findall(pattern_pdv,urlfetch.get(phudeviet_url).body):
			if 'Anh.png' in lang:lang="English"
			else:lang="Phudeviet"
			subs.append((href,lang,fn))
	notification=''
	if len(subs) == 0:
		url='http://subscene.com/subtitles/release?q=%s'%title.replace(' ','.')+'.'+year
		pattern='<a href="(/subtitles/.+?)">\s+<span class=".+?">\s*(.+?)\s+</span>\s+<span>\s+(.+?)\s+</span>'
		subs=re.findall(pattern,urlfetch.get(url=url,headers={'Cookie':'LanguageFilter=13,45'}).body)
		if subs:notification=u'tìm gần đúng!'

	if len(subs) == 0:
		mess(u'Không tìm thấy phụ đề của Video: %s'%title)
	
	fn = os.path.splitext(filename)[0].split('.x264')[0].replace(' ','.').replace('-','.').replace('*','.')
	ratlist=fn.split('.')
	for link,lang,name in subs:
		name=name.strip().replace(' ','.');rat=1;label='vie'
		if 'Vietnam' in lang:img='vi';url=subscene+link
		elif 'Phude' in lang:img='vi';url=link;name='[COLOR lime]phudeviet.org[/COLOR]: '+name
		else:
			img='en';url=subscene+link
			if addon.getSetting('trans_sub')=='false':label='eng'
		for i in ratlist:
			try:
				if re.search(i,name):rat+=1
			except:pass
		subtitles.append((name,url,label,img,str(rat)))
	items=list()
	for fn,link,label,img,rating in sorted(subtitles,cmp=lambda x,y:cmp(x[0],y[3]),reverse=True):
		item = xbmcgui.ListItem(label=label,label2=fn,iconImage=rating,thumbnailImage=img)
		url="plugin://%s/?action=download&link=%s&filename=%s&img=%s"%(service,link,fn,img)
		items.append((url, item, False))
	if items:
		xbmcplugin.addDirectoryItems(int(sys.argv[1]), items)
		if not filename:filename=title
		mess(u'Movie: %s'%filename,20000,'Xshare %s: Movie year - %s '%(notification,year))
开发者ID:vothanhdat,项目名称:xbmc.repo.xshare,代码行数:54,代码来源:xsharesub.py

示例11: getTvnet

def getTvnet(url):
	headers = {'User_Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0','Origin': 'http://vn.tvnet.gov.vn', 'Referer': url}
	matches = re.search(r"/\d+\/(.+)", url)
	channel = matches.group(1)
	r = urlfetch.get(url, headers=headers)
	matches = re.search(r"data-file=\"(.+?)\"", r.body)
	url_get = matches.group(1)
	url_get = url_get.replace('amp;', '')
	r = urlfetch.get(url_get, headers=headers)
	json_data = json.loads(r.body)
	video_url = json_data[0]["url"]
	return video_url+'|User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0&Referer=http://vn.tvnet.gov.vn'
开发者ID:vphuc81,项目名称:MyRepository,代码行数:12,代码来源:getlink.py

示例12: test_get_via_proxy

    def test_get_via_proxy(self):
        proxy = testlib.test_server_host[:-1]
        resp = urlfetch.get('http://www.example.com', proxies={'http':proxy})
        self.assertEqual(resp.status, 200)
        self.assertTrue(isinstance(resp.json, dict))
        self.assertTrue(isinstance(resp.text, urlfetch.unicode))

        proxy = proxy.split('://', 1)[1]
        resp = urlfetch.get('http://www.example.com', proxies={'http':proxy})
        self.assertEqual(resp.status, 200)
        self.assertTrue(isinstance(resp.json, dict))
        self.assertTrue(isinstance(resp.text, urlfetch.unicode))
开发者ID:SmartOwen,项目名称:urlfetch,代码行数:12,代码来源:test_proxy.py

示例13: test_content_encoding

    def test_content_encoding(self):
        url = testlib.url('/content-encoding/invalid-body')
        call_invalid_body = lambda: urlfetch.get(url).body
        self.assertRaises(urlfetch.ContentDecodingError, call_invalid_body)

        url = testlib.url('/content-encoding/invalid-header')
        call_invalid_header = lambda: urlfetch.get(url).body
        self.assertRaises(urlfetch.ContentDecodingError, call_invalid_header)

        url = testlib.url('/content-encoding/invalid-body/deflate')
        call_invalid_header_deflate = lambda: urlfetch.get(url).body
        self.assertRaises(urlfetch.ContentDecodingError, call_invalid_header_deflate)
开发者ID:ifduyue,项目名称:urlfetch,代码行数:12,代码来源:test_get.py

示例14: getKphim

def getKphim(url):
	matches = re.search(r"\?vid=(\d+)\?sid=(\d+)", url)
	vid = matches.group(1)
	sid = matches.group(2)
	token=urllib2.hashlib.md5(vid+'func'+sid).hexdigest()[1:]
	getlink = 'http://kphim.tv/embed/'+vid+'/'+sid+'/'+token
	response = urlfetch.get(getlink)
	matches = re.search(r"file:\s'(.+?)'", response.body)
	video_url = matches.group(1)
	response = urlfetch.get(video_url)
	rh = response.getheaders()
	video_url = rh[5][1]
	return video_url
开发者ID:vphuc81,项目名称:MyRepository,代码行数:13,代码来源:getlink.py

示例15: getmp3zing

def getmp3zing(url):	
	response = urlfetch.get(url)
	matches = re.search(r"data-xml=\"(.+?)\"", response.body)
	url_get= matches.group(1)
	if 'http' not in url_get:
		url_get = 'http://mp3.zing.vn'+url_get
	#lấy link nhạc
	response = urlfetch.get(url_get)
	json_data = json.loads(response.body)
	data = json_data["data"][0]["source_list"][1]
	if len(data) == 0:
		data = json_data["data"][0]["source_list"][0]
	return data
开发者ID:vphuc81,项目名称:MyRepository,代码行数:13,代码来源:getlink.py


注:本文中的urlfetch.get函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。