本文整理汇总了Python中twisted.web.client.downloadPage函数的典型用法代码示例。如果您正苦于以下问题:Python downloadPage函数的具体用法?Python downloadPage怎么用?Python downloadPage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了downloadPage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IMDBquery
def IMDBquery(self,string):
print "[IMDBquery]"
self["statusbar"].setText(_("IMDb Download completed"))
self.html2utf8(open("/tmp/imdbquery.html", "r").read())
self.generalinfos = self.generalinfomask.search(self.inhtml)
if self.generalinfos:
self.IMDBparse()
else:
if re.search("<title>(?:IMDb.{0,9}Search|IMDb Titelsuche)</title>", self.inhtml):
searchresultmask = re.compile("<tr> <td.*?img src.*?>.*?<a href=\".*?/title/(tt\d{7,7})/\".*?>(.*?)</td>", re.DOTALL)
searchresults = searchresultmask.finditer(self.inhtml)
self.resultlist = [(self.htmltags.sub('',x.group(2)), x.group(1)) for x in searchresults]
self["menu"].l.setList(self.resultlist)
if len(self.resultlist) > 1:
self.Page = 1
self.showMenu()
else:
self["detailslabel"].setText(_("No IMDb match."))
self["statusbar"].setText(_("No IMDb match."))
else:
splitpos = self.eventName.find('(')
if splitpos > 0 and self.eventName.endswith(')'):
self.eventName = self.eventName[splitpos+1:-1]
self["statusbar"].setText(_("Re-Query IMDb: %s...") % (self.eventName))
event_quoted = urllib.quote(self.eventName.decode('utf8').encode('latin-1','ignore'))
localfile = "/tmp/imdbquery.html"
fetchurl = "http://" + self.IMDBlanguage + "imdb.com/find?q=" + event_quoted + "&s=tt&site=aka"
print "[IMDB] Downloading Query " + fetchurl + " to " + localfile
downloadPage(fetchurl,localfile).addCallback(self.IMDBquery).addErrback(self.fetchFailed)
else:
self["detailslabel"].setText(_("IMDb query failed!"))
示例2: getOFDB
def getOFDB(self):
self.resetLabels()
if self.eventName is "":
s = self.session.nav.getCurrentService()
info = s and s.info()
event = info and info.getEvent(0) # 0 = now, 1 = next
if event:
self.eventName = event.getEventName()
if self.eventName is not "":
try:
pos = self.eventName.index(" (")
self.eventName=self.eventName[0:pos]
except ValueError:
pass
if self.eventName[-3:] == "...":
self.eventName = self.eventName[:-3]
for article in ["The", "Der", "Die", "Das"]:
if self.eventName[:4].capitalize() == article + " ":
self.eventName = self.eventName[4:] + ", " + article
self["statusbar"].setText(_("Query OFDb: %s...") % (self.eventName))
try:
self.eventName = urllib.quote(self.eventName)
except:
self.eventName = urllib.quote(self.eventName.decode('utf8').encode('ascii','ignore'))
localfile = "/tmp/ofdbquery.html"
fetchurl = "http://www.ofdb.de/view.php?page=suchergebnis&Kat=DTitel&SText=" + self.eventName
print "[OFDb] Downloading Query " + fetchurl + " to " + localfile
downloadPage(fetchurl,localfile).addCallback(self.OFDBquery).addErrback(self.fetchFailed)
else:
self["statusbar"].setText(_("Could't get Eventname"))
示例3: upgradeCB
def upgradeCB(self, result = None):
print "[UMMeteo] - upgrade:", result
if result:
print "\n[UMMeteo] - upgrade yes\n"
downloadPage('http://e2.areq.eu.org/ummeteo/update.py',PluginPath + '/update.py').addCallback(self.goupCB).addErrback(self.errorUpdate)
else:
print "[UMMeteo] upgrade cancel\n"
示例4: showDetails
def showDetails(self):
self["ratinglabel"].show()
self["castlabel"].show()
self["detailslabel"].show()
if self.resultlist and self.Page == 0:
link = self["menu"].getCurrent()[1]
title = self["menu"].getCurrent()[0]
self["statusbar"].setText(_("Re-Query OFDb: %s...") % (title))
localfile = "/tmp/ofdbquery2.html"
fetchurl = "http://www.ofdb.de/film/" + link
print "[OFDb] downloading query " + fetchurl + " to " + localfile
downloadPage(fetchurl,localfile).addCallback(self.OFDBquery2).addErrback(self.fetchFailed)
self["menu"].hide()
self.resetLabels()
self.Page = 1
if self.Page == 2:
self["extralabel"].hide()
self["poster"].show()
if self.ratingstars > 0:
self["starsbg"].show()
self["stars"].show()
self["stars"].setValue(self.ratingstars)
self.Page = 1
示例5: get_xmlfile
def get_xmlfile(self):
if self.isServerOnline():
xmlfile = "http://xml.weather.yahoo.com/forecastrss?w=%s&d=10&u=c" % config.plugins.yweather.weather_city.value
downloadPage(xmlfile, "/tmp/yweather.xml").addCallback(self.downloadFinished).addErrback(self.downloadFailed)
else:
self["text_now"].text = _('weatherserver not respond')
self.notdata = True
示例6: downloadThumbnail
def downloadThumbnail(self):
thumbUrl = self.list[self.idx][3]
if not thumbUrl.startswith("http://"):
thumbUrl = "%s%s"%(MAIN_PAGE, thumbUrl)
try:
req = urllib2.Request(thumbUrl)
url_handle = urllib2.urlopen(req)
headers = url_handle.info()
contentType = headers.getheader("content-type")
except:
contentType = None
if contentType:
if 'image/jpeg' in contentType:
self.thumb = "/tmp/zdf.jpg"
elif 'image/gif' in contentType:
self.thumb = "/tmp/zdf.gif"
elif 'image/png' in contentType:
self.thumb = "/tmp/zdf.png"
else:
print "[ZDF Mediathek] Unknown thumbnail content-type:", contentType
self.thumb = None
else:
self.thumb = None
if self.thumb:
downloadPage(thumbUrl, self.thumb).addCallback(self.downloadThumbnailCallback).addErrback(self.downloadThumbnailError)
else:
self.buildEntry(None)
示例7: get_xmlfile
def get_xmlfile(self):
# xmlfile = "http://weather.service.msn.com/data.aspx?weadegreetype=C&culture=ru-RU&weasearchstr=Moscow,Moscow-City,Russia&src=outlook"
xmlfile = "http://weather.service.msn.com/data.aspx?weadegreetype=%s&culture=%s&weasearchstr=%s&src=outlook" % (self.degreetype, self.language, self.city)
xmlfile1 = "http://weather.service.msn.com/data.aspx?weadegreetype=%s&culture=en-US&weasearchstr=%s&src=outlook" % (self.degreetype, self.city)
downloadPage(xmlfile, "/tmp/weathermsn.xml").addCallback(self.downloadFinished).addErrback(self.downloadFailed)
downloadPage(xmlfile1, "/tmp/weathermsn.xml").addCallback(self.downloadFinished).addErrback(self.downloadFailed)
示例8: buildList
def buildList(self):
if len(self.movies):
movie = self.movies[0]
thumbUrl = movie[4]
try:
req = urllib2.Request(thumbUrl)
url_handle = urllib2.urlopen(req)
headers = url_handle.info()
contentType = headers.getheader("content-type")
except:
contentType = None
if contentType:
if 'image/jpeg' in contentType:
self.thumb = "/tmp/ard.jpg"
elif 'image/gif' in contentType:
self.thumb = "/tmp/ard.gif"
elif 'image/png' in contentType:
self.thumb = "/tmp/ard.png"
else:
print "[ARD Mediathek] Unknown thumbnail content-type:", contentType
self.thumb = None
else:
self.thumb = None
if self.thumb:
downloadPage(thumbUrl, self.thumb).addCallback(self.downloadThumbnailCallback).addErrback(self.downloadThumbnailError)
else:
self.buildEntry(None)
else:
self["list"].setList(self.listMovies)
self.deactivateCacheDialog()
示例9: getCover
def getCover(self, url):
self.getCoverTimerStart()
print "getCover:", url
if url:
downloadPage(url, self.COVER_PIC_PATH).addCallback(self.showCover).addErrback(self.dataErrorP)
else:
self.showCoverNone()
示例10: mvidown
def mvidown(self, stadt):
downlink = "http://www.meinestadt.de/"+ stadt +"/bilder"
downname = "/tmp/.stadtindex"
stadd = stadt
if fileExists(downname):
os.system("rm -rf "+ downname)
downloadPage(downlink, downname).addCallback(self.jpgdown, stadd).addErrback(self.error)
示例11: GoogleImageCallback
def GoogleImageCallback(self, result):
global coverfiles
if self.nextGoogle:
self.currentGoogle = self.nextGoogle
self.nextGoogle = None
sendUrlCommand(self.currentGoogle, None, 10).addCallback(self.GoogleImageCallback).addErrback(self.Error)
return
self.currentGoogle = None
foundPos = result.find("unescapedUrl\":\"")
foundPos2 = result.find("\",\"url\":\"")
if foundPos != -1 and foundPos2 != -1:
url=result[foundPos+15:foundPos2]
if len(url)>15:
url= url.replace(" ", "%20")
print "download url: %s " % url
validurl = True
else:
validurl = False
print "[SHOUTcast] invalid cover url or pictureformat!"
if config.plugins.shoutcast.showcover.value:
self["cover"].doHide()
if validurl:
self.currentcoverfile = (self.currentcoverfile + 1) % len(coverfiles)
try:
os.unlink(coverfiles[self.currentcoverfile-1])
except:
pass
coverfile = coverfiles[self.currentcoverfile]
print "[SHOUTcast] downloading cover from %s to %s" % (url, coverfile)
downloadPage(url, coverfile).addCallback(self.coverDownloadFinished, coverfile).addErrback(self.coverDownloadFailed)
示例12: downloadThumbnail
def downloadThumbnail(self,thumbUrl):
if thumbUrl is not None:
thumbID = thumbUrl.rsplit("/",1)[1]
thumbFile = None
if not thumbUrl.startswith("http://"):
thumbUrl = "%s%s"%(MAIN_PAGE, thumbUrl)
try:
req = urllib2.Request(thumbUrl)
url_handle = urllib2.urlopen(req)
headers = url_handle.info()
contentType = headers.getheader("content-type")
except:
contentType = None
if contentType:
if 'image/jpeg' in contentType:
thumbFile = "/tmp/" + thumbID + ".jpg"
elif 'image/gif' in contentType:
thumbID = None
# thumbFile = "/tmp/" + thumbID + ".gif"
elif 'image/png' in contentType:
thumbFile = "/tmp/" + thumbID + ".png"
else:
print "[ZDF Mediathek] Unknown thumbnail content-type:", contentType
if thumbFile is not None:
if (os_path.exists(thumbFile) == True): #already downloaded
self.downloadThumbnailCallback(None, thumbFile, thumbID)
else:
if self.png_cache.get(thumbID, None) is None:
downloadPage(thumbUrl, thumbFile).addCallback(self.downloadThumbnailCallback, thumbFile, thumbID).addErrback(self.downloadThumbnailError, thumbID)
else:
self.updateEntry(thumbID, thumbFile)
示例13: getResults
def getResults(self, data):
data = data.replace('\/','')
if config.plugins.tmdb.firsthit.value:
# list = re.findall('"id":(.*?),.*?original_title":"(.*?)".*?"poster_path":"(.*?)".*?title":"(.*?)"', data, re.S)
list = re.findall('.*?"poster_path":"(.*?)".*?"id":(.*?),.*?"original_title":"(.*?)".*?"title":"(.*?)"', data, re.S)
if list:
for coverPath,id,otitle,title in list:
url_cover = "http://image.tmdb.org/t/p/%s/%s" % (config.plugins.tmdb.themoviedb_coversize.value, coverPath)
url = "http://api.themoviedb.org/3/movie/%s?api_key=8789cfd3fbab7dccf1269c3d7d867aff&append_to_response=releases,trailers,casts&language=%s" % (id, config.plugins.tmdb.lang.value)
cover = self.tempDir+id+".jpg"
downloadPage(url_cover, cover).addCallback(self.openMovie, title, url, cover, id).addErrback(self.dataError)
break
else:
print "[TMDb] no movie found."
self['searchinfo'].setText(_("No Movie information found for %s") % self.text)
else:
urls = []
# list = re.findall('"id":(.*?),.*?original_title":"(.*?)".*?"poster_path":"(.*?)".*?title":"(.*?)"', data, re.S)
list = re.findall('.*?"poster_path":"(.*?)".*?"id":(.*?),.*?"original_title":"(.*?)".*?"title":"(.*?)"', data, re.S)
if list:
for coverPath,id,otitle,title in list:
url_cover = "http://image.tmdb.org/t/p/%s/%s" % (config.plugins.tmdb.themoviedb_coversize.value, coverPath)
url = "http://api.themoviedb.org/3/movie/%s?api_key=8789cfd3fbab7dccf1269c3d7d867aff&append_to_response=releases,trailers,casts&language=%s" % (id, config.plugins.tmdb.lang.value)
#print "[tmbd] " + title, url_cover, "\n", url
urls.append(((title, url_cover, url, id),))
self['list'].setList(urls)
self.getInfo()
else:
print "[TMDb] no movie found."
self['searchinfo'].setText(_("No Movie information found for %s") % self.text)
示例14: getTempCover
def getTempCover(posterUrl):
if posterUrl is not None and config.EMC.movieinfo.coversave.value:
try:
coverpath = "/tmp/previewCover.jpg"
url = "http://image.tmdb.org/t/p/%s%s" % (config.EMC.movieinfo.coversize.value, posterUrl)
downloadPage(url, coverpath).addErrback(dataError)
except Exception, e:
print('[EMC] MovieInfo getTempCover exception failure: ', str(e))
示例15: loadThumbnail
def loadThumbnail(self, index, callback):
print "[YTB] YouTubeEntry::loadThumbnail()"
thumbnailUrl = self.getThumbnailUrl(index)
if thumbnailUrl is not None and self.getYouTubeId() is not None:
thumbnailFile = "/tmp/" + self.getYouTubeId() + "_" + str(index) + ".jpg"
self.thumbnail[str(index)] = None
cookie = {"entry" : self, "file" : thumbnailFile, "callback" : callback, "index" : index}
downloadPage(thumbnailUrl, thumbnailFile).addCallback(fetchFinished, cookie).addErrback(fetchFailed, cookie)