• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python urllib2.urlopen2函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: search_poster

def search_poster(id):
    url = 'http://www.kinopoisk.ru/level/17/film/%s' % id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read().decode('cp1251').encode('utf-8')
    coveritems = []
    watchvideopage.close()
    if '<table class="fotos' in data:
        coveritems = multiValue(data, '<table class="fotos.*?">(.*?)</table>', '<a href="(.*?)">')
        Coverart = coveritems[0]
        url2 = 'http://www.kinopoisk.ru%s' % Coverart
        watchrequest2 = Request(url2, None, std_headers)
        try:
            watchvideopage2 = urlopen2(watchrequest2)
        except (URLError, HTTPException, socket.error) as err:
            print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

        data2 = watchvideopage2.read().decode('cp1251').encode('utf-8')
        coveritem = ''
        coveritem = singleValue(data2, '<img style=".*?" id="image" src="(.*?)".*?/>')
        watchvideopage2.close()
    else:
        coveritem = 'None'
    return coveritem
开发者ID:Dima73,项目名称:enigma2-plugin-extensions-tmbd,代码行数:28,代码来源:kinopoiskall.py


示例2: poster_viemtmbd

def poster_viemtmbd(id):
    url = 'http://www.themoviedb.org%s' % id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read()
    search_results = []
    watchvideopage.close()
    if '<div id="images">' in data:
        content_results = singleValue(data, '<div id="images">(.*?)</div>')
        if content_results:
            idposters = re.compile('<img itemprop=".*?" class=".*?" id=".*?" src="(.*?)" width=".*?" height=".*?" />').findall(content_results)
            imagessaizes = re.compile('<img itemprop=".*?" class=".*?" id="(.*?)" src=".*?" width=".*?" height=".*?" />').findall(content_results)
            for imagessaize in imagessaizes:
                search_results.append('image:' + imagessaize)

            l = 0
            for idposter in idposters:
                if l < len(idposters):
                    search_results[l] = search_results[l] + '\n link:' + idposter + 'end'
                l += 1

    return search_results
开发者ID:Dima73,项目名称:enigma2-plugin-extensions-tmbd,代码行数:26,代码来源:kinopoiskall.py


示例3: poster_viem

def poster_viem(id):
    url = 'http://www.kinopoisk.ru/level/17/film/%s' % id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read().decode('cp1251').encode('utf-8')
    search_results = []
    watchvideopage.close()
    if '<table class="fotos' in data:
        content_results = singleValue(data, '<table class="fotos.*?">(.*?)</table>')
        if content_results:
            results = CrewRoleList3(content_results)
            idposters = re.compile('<a href="(.*?)" target="_blank" title="\xd0\x9e\xd1\x82\xd0\xba\xd1\x80\xd1\x8b\xd1\x82\xd1\x8c \xd0\xb2 \xd0\xbd\xd0\xbe\xd0\xb2\xd0\xbe\xd0\xbc \xd0\xbe\xd0\xba\xd0\xbd\xd0\xb5"></a>').findall(content_results)
            imageslinks = re.compile('<img  src="(.*?)".*?/></a>').findall(content_results)
            imagessaizes = re.compile('<span class="genre">(.*?)</span>').findall(results)
            for imagessaize in imagessaizes:
                search_results.append('size:' + imagessaize)

            i = 0
            for idposter in idposters:
                if i < len(idposters):
                    search_results[i] = search_results[i] + '\n\n (' + idposter + ')'
                i += 1

            l = 0
            for imageslink in imageslinks:
                if l < len(imageslinks):
                    search_results[l] = search_results[l] + '\n link:' + imageslink + 'end'
                l += 1

    return search_results
开发者ID:Dima73,项目名称:enigma2-plugin-extensions-tmbd,代码行数:34,代码来源:kinopoiskall.py


示例4: getMovieUrl

def getMovieUrl(url):
	req = Request(url, None, std_headers)
	try:
		txt = urlopen2(req).read()
	except (URLError, HTTPException, error), err:
		print "[ZDFMediaThek] Error: Unable to retrieve videopage - Error code: ", str(err)
		return ""
开发者ID:Haehnchen,项目名称:enigma2-plugins,代码行数:7,代码来源:plugin.py


示例5: getVideoUrl

	def getVideoUrl(self):
		'''VIDEO_FMT_PRIORITY_MAP = {
			'38' : 1, #MP4 Original (HD)
			'37' : 2, #MP4 1080p (HD)
			'22' : 3, #MP4 720p (HD)
			'18' : 4, #MP4 360p
			'35' : 5, #FLV 480p
			'34' : 6, #FLV 360p
		}'''
		VIDEO_FMT_PRIORITY_MAP = {
			'34' : 2, #FLV 360p
			'35' : 1, #FLV 480p
			'18' : 3, #MP4 360p
			'22' : 4, #MP4 720p (HD)
			'37' : 5, #MP4 1080p (HD)
			'38' : 6, #MP4 Original (HD)  
		}
		
		video_url = None
		video_id = str(self.getTubeId())

		links = {}
		watch_url = 'http://www.youtube.com/watch?v=%s&safeSearch=none'%video_id
		watchrequest = Request(watch_url, None, std_headers)

		try:
			print "[MyTube] trying to find out if a HD Stream is available",watch_url
			result = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			print "[MyTube] Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url
开发者ID:popazerty,项目名称:e2-gui,代码行数:31,代码来源:MyTubeService.py


示例6: getVideoUrl

    def getVideoUrl(self, entry):
        std_headers = {
            "User-Agent": "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6",
            "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
            "Accept-Language": "en-us,en;q=0.5",
        }

        VIDEO_FMT_PRIORITY_MAP = {"18": 4, "35": 5, "34": 6}  # MP4 360p  # FLV 480p  # FLV 360p

        if int(config.plugins.yttrailer.best_resolution.value) <= 1:
            VIDEO_FMT_PRIORITY_MAP["38"] = 1  # MP4 Original (HD)
            VIDEO_FMT_PRIORITY_MAP["22"] = 3  # MP4 720p (HD)

            if int(config.plugins.yttrailer.best_resolution.value) == 0:
                VIDEO_FMT_PRIORITY_MAP["37"] = 2  # MP4 1080p (HD)

        video_url = None
        video_id = str(self.getTubeId(entry))

        # Getting video webpage
        # URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
        watch_url = "http://www.youtube.com/watch?v=%s&gl=US&hl=en" % video_id
        watchrequest = Request(watch_url, None, std_headers)
        try:
            print "[YTTrailer] trying to find out if a HD Stream is available", watch_url
            watchvideopage = urlopen2(watchrequest).read()
        except (URLError, HTTPException, socket_error), err:
            print "[YTTrailer] Error: Unable to retrieve watchpage - Error code: ", str(err)
            return video_url
开发者ID:hd75hd,项目名称:enigma2-plugins,代码行数:30,代码来源:plugin.py


示例7: wgetUrlRefer

def wgetUrlRefer(target, refer):
	req = Request(target)
	req.add_header('Referer', refer)
	try:
		r = urlopen2(req)
		outtxt = r.read()
	except:
		outtxt = ''
	return outtxt
开发者ID:Firestorm552,项目名称:oe-alliance-plugins,代码行数:9,代码来源:plugin.py


示例8: poster_save

def poster_save(id):
    url2 = 'http://www.kinopoisk.ru%s' % id
    watchrequest2 = Request(url2, None, std_headers)
    try:
        watchvideopage2 = urlopen2(watchrequest2)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data2 = watchvideopage2.read().decode('cp1251').encode('utf-8')
    coveritem = ''
    coveritem = singleValue(data2, '<img style=".*?" id="image" src="(.*?)".*?/>')
    watchvideopage2.close()
    return coveritem
开发者ID:Dima73,项目名称:enigma2-plugin-extensions-tmbd,代码行数:13,代码来源:kinopoiskall.py


示例9: wgetUrl

def wgetUrl(target):
	std_headers = {
		'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6',
		'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
		'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
		'Accept-Language': 'en-us,en;q=0.5',
	}
	outtxt = Request(target, None, std_headers)
	try:
		outtxt = urlopen2(target, timeout = 5).read()
	except (URLError, HTTPException, socket.error):
		return ''
	return outtxt
开发者ID:Firestorm552,项目名称:oe-alliance-plugins,代码行数:13,代码来源:plugin.py


示例10: getVideoUrl

	def getVideoUrl(self, video_id):
		video_url = None

		if video_id is None or video_id == "":
			return video_url

		# Getting video webpage
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			#print "trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			print "Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url
开发者ID:R7UST,项目名称:oe-alliance-plugins,代码行数:15,代码来源:plugin.py


示例11: postto

def postto(url, datadict, headers={}, decodec='gbk'):
    params = urlencode(datadict)
    _logger.info('Post %s to %s, headers %s', params, url, headers)
    try:
        req = Request(url=url, data=params)
        for k,v in headers.items():
            req.add_header(k,v)
        con = urlopen2(req)
        if con:
            _logger.info("Hit %s %d", str(con), con.getcode())
            data = con.read(-1)
            return data.decode(decodec)
        else: 
            _logger.error("No data returned.")
            return None

    except Exception, err:
        _logger.error(str(err))
开发者ID:genzj,项目名称:list370kan-appfog,代码行数:18,代码来源:util.py


示例12: youtube

	def youtube(self, url, videoPrio=2):
		# this part is from mtube plugin
		print "got url: " + str(url)
		if videoPrio == 0:
			VIDEO_FMT_PRIORITY_MAP = {
				'38' : 6, #MP4 Original (HD)
				'37' : 5, #MP4 1080p (HD)
				'22' : 4, #MP4 720p (HD)
				'35' : 2, #FLV 480p
				'18' : 1, #MP4 360p
				'34' : 3, #FLV 360p
			}
		elif videoPrio == 1:
			VIDEO_FMT_PRIORITY_MAP = {
				'38' : 6, #MP4 Original (HD)
				'37' : 5, #MP4 1080p (HD)
				'22' : 1, #MP4 720p (HD)
				'35' : 3, #FLV 480p
				'18' : 2, #MP4 360p
				'34' : 4, #FLV 360p
			}
		else:
			VIDEO_FMT_PRIORITY_MAP = {
				'38' : 3, #MP4 Original (HD)
				'37' : 1, #MP4 1080p (HD)
				'22' : 2, #MP4 720p (HD)
				'35' : 5, #FLV 480p
				'18' : 4, #MP4 360p
				'34' : 6, #FLV 360p
			}
		video_url = None
		url = url.replace('/embed/', '/watch?v=')
		id = re.findall('watch.v=(.*\D)', url, re.S)
		video_id = id[0]
		# Getting video webpage
		#URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=DE&hl=de' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			print "[youtubeUrl] trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			return "Error: Unable to retrieve watchpage - Error code: %s" % str(err)
开发者ID:lilmuck,项目名称:lilmuck,代码行数:43,代码来源:stream.py


示例13: search_comets

def search_comets(id):
    url = 'http://www.kinopoisk.ru/level/1/film/' + id
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    content = watchvideopage.read().decode('cp1251').encode('utf-8')
    watchvideopage.close()
    search_results = []
    content_results = content[content.find('<p class="more_random">'):content.find('\xd0\x94\xd0\xbb\xd1\x8f \xd1\x82\xd0\xbe\xd0\xb3\xd0\xbe \xd1\x87\xd1\x82\xd0\xbe\xd0\xb1\xd1\x8b \xd0\xb4\xd0\xbe\xd0\xb1\xd0\xb0\xd0\xb2\xd0\xb8\xd1\x82\xd1\x8c \xd1\x80\xd0\xb5\xd1\x86\xd0\xb5\xd0\xbd\xd0\xb7\xd0\xb8\xd1\x8e \xd0\xbd\xd0\xb0 \xd1\x84\xd0\xb8\xd0\xbb\xd1\x8c\xd0\xbc, \xd0\xbd\xd0\xb5\xd0\xbe\xd0\xb1\xd1\x85\xd0\xbe\xd0\xb4\xd0\xb8\xd0\xbc\xd0\xbe')]
    if content_results:
        results = CrewRoleList2(content_results)
        names = normilize_string(singleValue(results, '<p class="profile_name"><s></s><a href=".*?" itemprop="name">(.*?)</a></p>'))
        titleitems = normilize_string(singleValue(results, '<span class="_reachbanner_" itemprop="reviewBody">(.*?)</span></p> </div>'))
        iditems = normilize_string(singleValue(results, '<p class="sub_title" id=".*?">(.*?)</p>'))
        search = '%s\n\n%s\n\n%s' % (names, iditems, titleitems)
        search_results.append(search)
    return search_results
开发者ID:Dima73,项目名称:enigma2-plugin-extensions-tmbd,代码行数:20,代码来源:kinopoiskall.py


示例14: search_tmbd

def search_tmbd(title):
    url = 'http://www.themoviedb.org/search?query=%s' % title
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read()
    search_results = []
    watchvideopage.close()
    if '<div class="search_results movie ">' in data:
        content_results = singleValue(data, '<div class="search_results movie ">(.*?)<div class="search_results collection hide">')
        if content_results:
            iditems = re.compile('<a id=".*?" class="result" href="(.*?)" title=".*?" alt=".*?">').findall(content_results)
            years = re.compile('<span class="release_date"> (.*?) <span class=".*?"></span></span>').findall(content_results)
            directors = re.compile('<span class="genres">(.*?)</span>').findall(content_results)
            images = re.compile('<img class="poster lazyload" data-src="(.*?)" .*? alt=".*?">').findall(content_results)
            titleitems = re.compile('<a id=".*?" class="result" href=".*?" title="(.*?)" alt=".*?">').findall(content_results)
            for titleitem in titleitems:
                search_results.append(titleitem)

            d = 0
            for director in directors:
                if d < len(directors):
                    search_results[d] = search_results[d] + '\n year: ' + years[d] + '\n \xd1\x80\xd0\xb5\xd0\xb6. ' + director
                d += 1

            l = 0
            for iditem in iditems:
                if l < len(iditems):
                    search_results[l] = search_results[l] + '\n' + 'id:' + iditem + 'end'
                l += 1

            e = 0
            for image in images:
                if e < len(images):
                    search_results[e] = search_results[e] + '\n' + 'image:' + image + 'ends'
                e += 1

    return search_results
开发者ID:Dima73,项目名称:enigma2-plugin-extensions-tmbd,代码行数:41,代码来源:kinopoiskall.py


示例15: search_postermp3

def search_postermp3(url):
    watchrequest = Request(url, None, std_headers)
    try:
        watchvideopage = urlopen2(watchrequest)
    except (URLError, HTTPException, socket.error) as err:
        print '[Kinopoisk] Error: Unable to retrieve page - Error code: ', str(err)

    data = watchvideopage.read()
    search_results = []
    cover = ''
    watchvideopage.close()
    if 'src="' in data:
        coveritems = re.compile('src="(.*?)"').findall(data)
        for coveritem in coveritems:
            if 'http://' in coveritem:
                if '&imgurl=' in coveritem:
                    search_results.append(singleValue(coveritem, '&imgurl=(.*?)&w='))
                else:
                    search_results.append(coveritem)

    return search_results
开发者ID:Dima73,项目名称:enigma2-plugin-extensions-tmbd,代码行数:21,代码来源:kinopoiskall.py


示例16: getVideoUrl

	def getVideoUrl(self):
		VIDEO_FMT_PRIORITY_MAP = {
			'38' : 1, #MP4 Original (HD)
			'37' : 2, #MP4 1080p (HD)
			'22' : 3, #MP4 720p (HD)
			'18' : 4, #MP4 360p
			'35' : 5, #FLV 480p
			'34' : 6, #FLV 360p
		}
		video_url = None
		video_id = str(self.getTubeId())

		# Getting video webpage
		#URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
		watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
		watchrequest = Request(watch_url, None, std_headers)
		try:
			print "[MyTube] trying to find out if a HD Stream is available",watch_url
			watchvideopage = urlopen2(watchrequest).read()
		except (URLError, HTTPException, socket.error), err:
			print "[MyTube] Error: Unable to retrieve watchpage - Error code: ", str(err)
			return video_url
开发者ID:4doe,项目名称:enigma2-plugins,代码行数:22,代码来源:MyTubeService.py


示例17: __get_tick_quotes_finam__

def __get_tick_quotes_finam__(symbol, start_date, end_date, verbose=False):
    start_date = datetime.strptime(start_date, "%Y%m%d").date()
    end_date = datetime.strptime(end_date, "%Y%m%d").date()
    delta = end_date - start_date
    data = DataFrame()
    for i in range(delta.days + 1):
        day = timedelta(i)
        url = __get_url__(symbol, periods["tick"], start_date + day, start_date + day, verbose)
        req = Request(url)
        req.add_header("Referer", "http://www.finam.ru/analysis/profile0000300007/default.asp")
        r = urlopen2(req)
        try:
            tmp_data = read_csv(r, index_col=0, parse_dates={"index": [0, 1]}, sep=";").sort_index()
            if data.empty:
                data = tmp_data
            else:
                data = data.append(tmp_data)
        except Exception:
            print ("error on data downloading {} {}".format(symbol, start_date + day))

    data.columns = [symbol + "." + i for i in ["Last", "Vol", "Id"]]
    return data
开发者ID:dimitrovs,项目名称:finamdownloader,代码行数:22,代码来源:finamquote_dwl.py


示例18: send_captcha

def send_captcha(key, fobj):
    items = []
    items.append(MultipartParam(name='key', value=key))
    items.append(MultipartParam(name='method', value='post'))
    items.append(MultipartParam(name='file', filename='captcha.jpg',
                                fileobj=fobj))

    data, headers = multipart_encode(items)
    req = Request('http://antigate.com/in.php', data, headers)
    res = urlopen2(req)
    if res.code == 200:
        chunks = res.read().split('|')
        if len(chunks) == 2:
            return int(chunks[1])
        else:
            msg = chunks[0]
            raise CaptchaError(msg)
    else:
        msg = '%s %s' % (res.code, res.msg)
        raise CaptchaError(msg)
    print(res.info())
    return res.read()
开发者ID:craw1er,项目名称:grab,代码行数:22,代码来源:antigate.py


示例19: closing

import distutils.spawn
import hashlib
import os
import sys
import tarfile
import shutil

try:
    from urllib.request import urlopen
except ImportError:
    # We are in python2
    from urllib2 import urlopen as urlopen2
    from contextlib import closing
    urlopen = lambda url: closing(urlopen2(url))

with open('src/snapshots.txt') as f:
    lines = f.readlines()

date = lines[0]
linux32 = lines[1]
linux64 = lines[2]
mac32 = lines[3]
mac64 = lines[4]
win32 = lines[5]
win64 = lines[6]
triple = sys.argv[1]

ts = triple.split('-')
arch = ts[0]
if len(ts) == 2:
    vendor = 'unknown'
开发者ID:DiamondLovesYou,项目名称:cargo,代码行数:31,代码来源:dl-snapshot.py


示例20: getWeatherThread

	def getWeatherThread(self):
		global g_updateRunning
		id = ""
		name = ""
		temp = ""
		temp_max = ""
		temp_min = ""
		if config.plugins.MetrixWeather.weatherservice.value == "MSN":
			text = "MetrixHDWeatherStandalone lookup for City " + str(self.cityname)
		else:
			text = "MetrixHDWeatherStandalone lookup for ID " + str(self.woeid)
		if self.check:
			self.writeCheckFile(text)
		print text

		if config.plugins.MetrixWeather.weatherservice.value == "MSN":
			units = 'C'
			if config.plugins.MetrixWeather.tempUnit.value == "Fahrenheit":
				units ='F'
			language = config.osd.language.value.replace('_', '-')
			if language == 'en-EN':
				language = 'en-US'
			city="%s" % self.cityname
			feedurl = "http://weather.service.msn.com/data.aspx?weadegreetype=%s&culture=%s&weasearchstr=%s&src=outlook" % (units,language,urllib2_quote(city))
			msnrequest = Request(feedurl, None, std_headers)
			try:
				msnpage = urlopen2(msnrequest)
			except (URLError) as err:
				self.errorCallback(message = str(err))
				return
			g_updateRunning = False
			try:
				content = msnpage.read()
				msnpage.close()
				dom = parseString(content)
				currentWeather = dom.getElementsByTagName('weather')[0]
				titlemy = currentWeather.getAttributeNode('weatherlocationname')
				config.plugins.MetrixWeather.currentLocation.value = titlemy.nodeValue
				name = titlemy.nodeValue
				idmy =  currentWeather.getAttributeNode('weatherlocationcode')
				id = idmy.nodeValue
				currentWeather = dom.getElementsByTagName('current')[0]
				currentWeatherCode = currentWeather.getAttributeNode('skycode')
				if config.plugins.MetrixWeather.type.value:
					config.plugins.MetrixWeather.currentWeatherCode.value = currentWeatherCode.nodeValue
				else:
					config.plugins.MetrixWeather.currentWeatherCode.value = self.ConvertConditionMSN(currentWeatherCode.nodeValue)
				currentWeatherTemp = currentWeather.getAttributeNode('temperature')
				temp = currentWeatherTemp.nodeValue
				config.plugins.MetrixWeather.currentWeatherTemp.value = currentWeatherTemp.nodeValue
				currenthumidity = currentWeather.getAttributeNode('humidity')
				config.plugins.MetrixWeather.currentWeatherhumidity.value = currenthumidity.nodeValue
				currentwinddisplay = currentWeather.getAttributeNode('winddisplay')
				config.plugins.MetrixWeather.currentWeatherwinddisplay.value = currentwinddisplay.nodeValue
				currentwindspeed = currentWeather.getAttributeNode('windspeed')
				config.plugins.MetrixWeather.currentWeatherwindspeed.value = currentwindspeed.nodeValue
				currentshortday = currentWeather.getAttributeNode('shortday')
				config.plugins.MetrixWeather.currentWeathershortday.value = currentshortday.nodeValue
				currentday = currentWeather.getAttributeNode('day')
				config.plugins.MetrixWeather.currentWeatherday.value = currentday.nodeValue
				currentdate = currentWeather.getAttributeNode('date')
				config.plugins.MetrixWeather.currentWeatherdate.value = currentdate.nodeValue
				currentfeelslike = currentWeather.getAttributeNode('feelslike')
				config.plugins.MetrixWeather.currentWeatherfeelslike.value = currentfeelslike.nodeValue
				currentobservationtime = currentWeather.getAttributeNode('observationtime')
				config.plugins.MetrixWeather.currentWeatherobservationtime.value = currentobservationtime.nodeValue
				currentWeatherText = currentWeather.getAttributeNode('skytext')
				config.plugins.MetrixWeather.currentWeatherText.value = currentWeatherText.nodeValue
				n = 1
				currentWeather = dom.getElementsByTagName('forecast')[n]
				currentWeatherCode = currentWeather.getAttributeNode('skycodeday')
				if config.plugins.MetrixWeather.type.value:
					config.plugins.MetrixWeather.forecastTodayCode.value = currentWeatherCode.nodeValue
				else:
					config.plugins.MetrixWeather.forecastTodayCode.value = self.ConvertConditionMSN(currentWeatherCode.nodeValue)
				currentWeatherTemp = currentWeather.getAttributeNode('high')
				temp_max  = currentWeatherTemp.nodeValue
				config.plugins.MetrixWeather.forecastTodayTempMax.value = currentWeatherTemp.nodeValue
				currentWeatherTemp = currentWeather.getAttributeNode('low')
				temp_min = currentWeatherTemp.nodeValue
				config.plugins.MetrixWeather.forecastTodayTempMin.value = currentWeatherTemp.nodeValue
				currentWeatherText = currentWeather.getAttributeNode('skytextday')
				config.plugins.MetrixWeather.forecastTodayText.value = currentWeatherText.nodeValue
				currentWeather = dom.getElementsByTagName('forecast')[n + 1]
				currentWeatherCode = currentWeather.getAttributeNode('skycodeday')
				if config.plugins.MetrixWeather.type.value:
					config.plugins.MetrixWeather.forecastTomorrowCode.value = currentWeatherCode.nodeValue
				else:
					config.plugins.MetrixWeather.forecastTomorrowCode.value = self.ConvertConditionMSN(currentWeatherCode.nodeValue)
				currentWeatherTemp = currentWeather.getAttributeNode('high')
				config.plugins.MetrixWeather.forecastTomorrowTempMax.value = currentWeatherTemp.nodeValue
				currentWeatherTemp = currentWeather.getAttributeNode('low')
				config.plugins.MetrixWeather.forecastTomorrowTempMin.value = currentWeatherTemp.nodeValue
				currentWeatherText = currentWeather.getAttributeNode('skytextday')
				config.plugins.MetrixWeather.forecastTomorrowText.value = currentWeatherText.nodeValue
				currentWeatherdate = currentWeather.getAttributeNode('date')
				config.plugins.MetrixWeather.forecastTomorrowdate.value = currentWeatherdate.nodeValue
				currentWeatherday = currentWeather.getAttributeNode('day')
				config.plugins.MetrixWeather.forecastTomorrowday.value = currentWeatherday.nodeValue
				currentWeathershortday = currentWeather.getAttributeNode('shortday')
#.........这里部分代码省略.........
开发者ID:openatv,项目名称:MetrixHD,代码行数:101,代码来源:MetrixHDWeatherUpdaterStandalone.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python urllib2.HTTPDigestAuthHandler类代码示例发布时间:2022-05-27
下一篇:
Python urllib2.urlopen函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap