utils.py 文件源码

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

项目:ProxyPool 作者: Germey 项目源码 文件源码
def get_page(url, options={}):
    ua = UserAgent()
    base_headers = {
        'User-Agent':  ua.random,
        'Accept-Encoding': 'gzip, deflate, sdch',
        'Accept-Language': 'zh-CN,zh;q=0.8'
    }
    headers = dict(base_headers, **options)
    print('Getting', url)
    try:
        r = requests.get(url, headers=headers)
        print('Getting result', url, r.status_code)
        if r.status_code == 200:
            return r.text
    except ConnectionError:
        print('Crawling Failed', url)
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号