百度的图片与普通网站的图片不同,是转换成了base64位的,无法用普通方法抓取,如下,求指教!
百度的图片我抓到的网址是下面这样: - http://img2.imgtn.bdimg.com/it/u=4014691150,3646257854&fm=27&gp=0.jpg
复制代码
直接用浏览器访问是不成功的,提示页面未找到,我分析了一下,图片实际是用ajax转换成base64存在src里面: - src="data:image/jpeg;base64,/9j/4AAQSkZJRgA
复制代码
于是我尝试使用下级线索,爬详情页面,但是详情页面的规则测试结果中的网址是不对的,与实际结果不同,其格式也与浏览器里面分析出来的不同,测试结果如下: - <p class="p2" style="font-stretch: normal; font-size: 11px; line-height: normal; font-family: Monaco; color: rgb(115, 115, 115); -webkit-text-stroke: rgb(115, 115, 115);"><span class="s1" style="font-kerning: none;"><百度图片详情></span></p><p class="p2" style="font-stretch: normal; font-size: 11px; line-height: normal; font-family: Monaco; color: rgb(115, 115, 115); -webkit-text-stroke: rgb(115, 115, 115);"><span class="s1" style="font-kerning: none;"><span class="Apple-converted-space"> </span><item></span></p><p class="p2" style="font-stretch: normal; font-size: 11px; line-height: normal; font-family: Monaco; color: rgb(115, 115, 115); -webkit-text-stroke: rgb(115, 115, 115);"><span class="s1" style="font-kerning: none;"><span class="Apple-converted-space"> </span><图片网址>https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1512357457508&di=e3ca5c62d1bb8c35bc435fab9a018a60&imgtype=0&src=http%3A%2F%2Fcdn.feeyo.com%2Fpic%2F20150206%2F201502061243171.jpg</图片网址></span></p><p class="p2" style="font-stretch: normal; font-size: 11px; line-height: normal; font-family: Monaco; color: rgb(115, 115, 115); -webkit-text-stroke: rgb(115, 115, 115);"><span class="s1" style="font-kerning: none;"><span class="Apple-converted-space"> </span></item></span></p><p class="p2" style="font-stretch: normal; font-size: 11px; line-height: normal; font-family: Monaco; color: rgb(115, 115, 115); -webkit-text-stroke: rgb(115, 115, 115);"><span class="s1" style="font-kerning: none;"></百度图片详情></span></p>
复制代码
浏览器分析的网址: - src="http://cdn.feeyo.com/pic/20150206/201502061243171.jpg"<span class="Apple-converted-space"> </span>
复制代码
|
|
|
|
|
共 7 个关于本帖的回复 最后回复于 2017-12-4 17:17