# -*- coding: utf-8 -*-
import re
import sys
import requests
reload(sys)
sys.setdefaultencoding("utf-8")
if __name__ == '__main__':
url = 'https://movie.douban.com/subject/1433330/photos?type=W'
# 获取网页源码
html = requests.get(url)
# 抓每个图片链接
pic_url = re.findall('<img src="https://(.*?)" />', html.text, re.S) #此链接为预览链接
i = 0
for each in pic_url:
raw = re.sub('thumb','raw',each,re.S) //将预览链接中的thumb替换成raw,便成了高清图片链接
print 'now download..'+'https://'+raw
pic = requests.get('https://'+raw)
f = open('hp\\'+str(i)+'.jpg','wb')
f.write(pic.content)
f.close()
i += 1
刚开始学爬虫,爬豆瓣电影的壁纸练手。现在程序可以跑下来,不返回错,但是下载的图片是失败的,response 返回 403 forbidden。
我这样想问题的原因对吗?
因为我想下高清的,但是豆瓣查看高清壁纸前,需要登录,但我的程序是没有登录的,所以出现403是吗?所以我得模拟登陆是吗?
刚注册,木有悬赏币。。谢谢