main.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:YoutubeTV 作者: dude56987 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号