def grabWebpage(self,url):
'''
Download the url, strip line endings, and return a string.
'''
userAgent=addonObject.getSetting('userAgent')
header = {'User-Agent': userAgent,
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'Accept-Encoding': 'none',
'Accept-Language': 'en-US,en;q=0.8',
'Connection': 'keep-alive'}
requestObject = urllib2.Request(url,headers=header)
# get the youtube users webpage
try:
# try to download the webpage
webpageText=urllib2.urlopen(requestObject)
except:
popup('YoutubeTV', ('Failed to load webpage "'+str(url)+'"'))
# download failed, return blank string
return str()
temp=''
for line in webpageText:
# mash everything into a string because they use code obscification
# also strip endlines to avoid garbage
temp+=(line.strip())
return temp
评论列表
文章目录