1. If you look at The Google Image Crawling Python script that someone has already created, you can just do this.
try:
output_file = open(path, 'wb')
output_file.write(data)
output_file.close()
except OSError as e:
# If there is a problem with the OS...
except IOError as e:
# When there is a problem writing the file...
2. This isn't the problem... [strong] You don't want to save those images the way you do.
For example, we searched out focus background and simulated "crawling" with a good program called Postman The result is that these img
tags fall (as you gave in the shot).
<img height="73" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRTOnuOvOOdhatyAEgGLu5ZWy47sec9K5yU0HCDwGs-775g0Ot3nfgc0A" width="110" alt="out focus background에 대한 이미지 검색결과">
And if you open the image, it looks like this. It's 150 by 84.
I think it changes to this form only when js is executed after loading the page. Then I think I can get a "saveable" image using the link in the a
tag.
<a jsname="hSRGPd" href="/imgres?imgurl=https%3A%2F%2Fthumbs.dreamstime.com%2Ft%2Fgreen-natural-background-out-focus-forest-bokeh-40681278.jpg&imgrefurl=https%3A%2F%2Fwww.dreamstime.com%2Ffresh-green-bio-abstract-blurred-background-spring-summer-abstract-nature-background-green-blurred-background-green-bokeh-out-image122604484&docid=gR2HU0bA_lu_1M&tbnid=HRYs1XvtajYhGM%3A&vet=10ahUKEwiy0NWTkIXfAhVJxrwKHQxNAmMQMwhMKBEwEQ..i&w=240&h=160&client=firefox-b-ab&bih=966&biw=862&q=out%20focus%20background&ved=0ahUKEwiy0NWTkIXfAhVJxrwKHQxNAmMQMwhMKBEwEQ&iact=mrc&uact=8" jsaction="fire.ivg_o;mouseover:str.hmov;mouseout:str.hmou" class="rg_l" rel="noopener" style="width: 233px; height: 192px; left: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%;">
<div class="THL2l"></div>
<img class="rg_icrg_i" data-src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSMsyc_VQeuTv5P47F2uYrBRyQyu09APtKgLiH24N4BKrBvs1Dh" jsaction="load:str.tbn" alt="out focus background" onload="type of google==='object'&amp;&google.aftigh="&amp;amp;amp;2;amp;amp;amp;amp;amp;amp;amp;2;"2;lt;n":-3px;margin-right:-4px;margin-top:16px" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSMsyc_VQeuTv5P47F2uYrBRyQyu09APtKgLiH24N4BKrBvs1Dh">
<div class="rg_ilmbg" style="bottom:16px;left:0px;max-width:233px"> 240 × 160 </div>
</a>
© 2024 OneMinuteCode. All rights reserved.