sbi.py icon indicating copy to clipboard operation
sbi.py copied to clipboard

sbi.search_by exception

Open Glench opened this issue 8 years ago • 1 comments

 File "/app/image_search_server.py", line 88, in get_google_image
  result = sbi.search_by(url)
File "/app/sbi.py", line 155, in search_by
  url = a['href']
File "/app/.heroku/python/lib/python2.7/site-packages/bs4/element.py", line 905, in __getitem__
  return self.attrs[key]
KeyError: 'href'

It looks like Google Images changed its results. Now elements look something like this apparently (printed out during debugging variable 'a' from exception above):

<a class="rg_l" jsaction="fire.ivg_o;mouseover:str.hmov;mouseout:str.hmou" rel="noopener" style="background:rgb(72,46,27)"><img alt="Image result for helena bonham carter sweeney todd" class="rg_ic rg_i" data-sz="f" jsaction="load:str.tbn" name="W2gzy60qg_ZHfM:" onload="google.aft&amp;&amp;google.aft(this)"/><div class="rg_anbg"><span class="rg_an">504 × 740</span></div><div class="_aOd rg_ilm"><div class="rg_ilmbg"><span class="rg_ilmn"> 504 × 740 - namespedia.com </span></div></div></a>

Glench avatar Dec 30 '16 05:12 Glench

Thank you for reporting this error, I will check it out. Maybe it's time to release a new version.

vinta avatar Dec 30 '16 08:12 vinta