utils.py 文件源码

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

项目:plugin.video.auvio 作者: rickybiscus 项目源码 文件源码
def request_url(url, referer='http://www.google.com'):
    common.plugin.log('request_url : %s' % url)
    req = urllib2.Request(url)
    req.addheaders = [('Referer', referer),('Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100101 Firefox/11.0 ( .NET CLR 3.5.30729)')]

    try:
        response = urllib2.urlopen(req)
        data = response.read()
        response.close()
    except urllib2.URLError as e:
        common.plugin.log_error("Remote request error for URL %s: %r" % (url,e))
        return
    except socket.timeout, e:
        common.plugin.log_error("Remote request error for URL %s: %r" % (url,e))
        return

    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号