requests.exceptions.MissingSchema

requests.exceptions.MissingSchema: Invalid URL '//p9.pstatp.com/list/pgc-image/1538380201743a84869e0b6': No schema supplied. Perhaps you meant http:////p9.pstatp.com/list/pgc-image/1538380201743a84869e0b6?

碰到这个问题的地方来源:爬取今日头条图片

报错写法:

response = requests.get(item.get("image"))

 并且注意报错的地方,说我们搜索的可能是http:////p9.pstatp.com/list/pgc-image/1538380201743a84869e0b6?,但这样去搜索栏里是搜索不到内容的

正确写法:

response = requests.get("http:" + item.get("image"))

因此在在将请求头的时候要注意一点。

posted on 2018-10-02 17:28  zengsf  阅读(11235)  评论(0编辑  收藏  举报

导航