import requests
    session = requests.session()
    carProposalUrl = "www.caaaa.com.cn/aaaa/aaaaa/carProposalproposal.do"
    carProposalHeaders ={
        "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "Accept-Encoding":"gzip, deflate, br",
        "Accept-Language":"zh-CN,zh;q=0.8",
        "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.7 Safari/537.36",
        "Referer": "http://www.chinalife-p.com.cn/view/default/modal/insuranceCar.html",
        "Upgrade-Insecure-Requests":"1",
        "Connection":"keep-alive",
        "Host":"www.chinalife.com.cn"","
    }

    carProposalUrlParams = {
        "proposalArea": "3110000",
    }
    carProposal = session.get(carProposalUrl, params=carProposalUrlParams, headers=carProposalHeaders).text

    print carProposal
requests.exceptions.MissingSchema: Invalid URL 'xxxxxxxxxxxxx': No schema supplied. Perhaps you meant xxxxxxxxxxxxx
在爬虫的时候遇到这个问题,然后是各种百度,还是不能发现原因,最后向老司机请教后,原来在carProposalUrl = "www.caaaa.com.cn/aaaa/aaaaa/carProposalproposal.do"中的www.前加 http:// 即可

转载于:https://www.cnblogs.com/xuchunlin/p/6774377.html

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐