正在尝试从 google 抓取图像

Trying to scrape image from google

我正尝试按照此视频中的教程从 google 中抓取图像。 https://www.youtube.com/watch?v=ZAUNEEtzsrg&t=859s

但我在这里发现我的代码无法与视频获得相同的结果。 我的意思是我的结果必须显示 'imgres?imgurl' 以便我可以访问图像的原始 link。但是我的结果里没有'imgres?imgurl'

import urllib
import mechanize
from bs4 import BeautifulSoup 
from urlparse import urlparse

def getPic(search):
    try:
        browser = mechanize.Browser()
        browser.set_handle_robots(False)
        browser.addheaders = [('User-agent','Mozilla')]

        htmltext = browser.open("https://www.google.co.kr/search?site=&tbm=isch&source=hp&biw=1204&bih=673&q=cars&oq=cars&gws_rd=cr&ei=Z6XrWOryEMia8QX7x5aYCg")
        img_urls = []
        formatted_images = []
        soup = BeautifulSoup(htmltext, "html.parser")
        results = soup.findAll("a")

        print results

    except:
        print "error"


getPic("occupy wall street")

我的结果如下:

[<a class="gbzt" href="https://www.google.co.kr/search?tab=iw" id="gb_1" onclick="gbar.logger.il(1,{t:1});"><span class="gbtb2"></span><span class="gbts">\xb0\xcb\xbb\xf6</span></a>, <a class="gbzt gbz0l gbp1" href="https://www.google.co.kr/imghp?hl=ko&amp;tab=ii" id="gb_2" onclick="gbar.logger.il(1,{t:2});"><span class="gbtb2"></span><span class="gbts">\xc0\xcc\xb9\xcc\xc1\xf6</span></a>, <a class="gbzt" href="https://maps.google.co.kr/maps?hl=ko&amp;tab=il" id="gb_8" onclick="gbar.logger.il(1,{t:8});"><span class="gbtb2"></span><span class="gbts">\xc1\xf6\xb5\xb5</span></a>, <a class="gbzt" href="https://play.google.com/?hl=ko&amp;tab=i8" id="gb_78" onclick="gbar.logger.il(1,{t:78});"><span class="gbtb2"></span><span class="gbts">Play</span></a>, <a class="gbzt" href="https://www.youtube.com/results?gl=KR&amp;tab=i1" id="gb_36" onclick="gbar.logger.il(1,{t:36});"><span class="gbtb2"></span><span class="gbts">YouTube</span></a>, <a class="gbzt" href="https://news.google.co.kr/nwshp?hl=ko&amp;tab=in" id="gb_5" onclick="gbar.logger.il(1,{t:5});"><span class="gbtb2"></span><span class="gbts">\xb4\xba\xbd\xba</span></a>, <a class="gbzt" href="https://mail.google.com/mail/?tab=im" id="gb_23" onclick="gbar.logger.il(1,{t:23});"><span class="gbtb2"></span><span class="gbts">Gmail</span></a>, <a class="gbzt" href="https://drive.google.com/?tab=io" id="gb_49" onclick="gbar.logger.il(1,{t:49});"><span class="gbtb2"></span><span class="gbts">\xb5\xe5\xb6\xf3\xc0\xcc\xba\xea</span></a>, <a aria-haspopup="true" aria-owns="gbd" class="gbgt" href="https://www.google.co.kr/intl/ko/options/" id="gbztm" onclick="gbar.tg(event,this)"><span class="gbtb2"></span><span class="gbts gbtsa" id="gbztms"><span id="gbztms1">\xb4\xf5\xba\xb8\xb1\xe2</span><span class="gbma"></span></span></a>, <a class="gbmt" href="https://www.google.com/calendar?tab=ic" id="gb_24" onclick="gbar.logger.il(1,{t:24});">\xc4\xb6\xb8\xb0\xb4\xf5</a>, <a class="gbmt" href="https://translate.google.co.kr/?hl=ko&amp;tab=iT" id="gb_51" onclick="gbar.logger.il(1,{t:51});">\xb9\xf8\xbf\xaa</a>, <a class="gbmt" href="https://www.google.co.kr/search?hl=ko&amp;tbo=u&amp;tbm=bks&amp;source=og&amp;tab=ip" id="gb_10" onclick="gbar.logger.il(1,{t:10});">\xb5\xb5\xbc\xad</a>, <a class="gbmt" href="https://www.blogger.com/?tab=ij" id="gb_30" onclick="gbar.logger.il(1,{t:30});">Blogger</a>, <a class="gbmt" href="https://photos.google.com/?tab=iq&amp;pageId=none" id="gb_31" onclick="gbar.logger.il(1,{t:31});">\xbb\xe7\xc1\xf8</a>, <a class="gbmt" href="https://www.google.co.kr/search?hl=ko&amp;tbo=u&amp;tbm=vid&amp;source=og&amp;tab=iv" id="gb_12" onclick="gbar.logger.il(1,{t:12});">\xb5\xbf\xbf\xb5\xbb\xf3</a>, <a class="gbmt" href="https://docs.google.com/document/?usp=docs_alc" id="gb_25" onclick="gbar.logger.il(1,{t:25});">\xb9\xae\xbc\xad</a>, <a class="gbmt" href="https://www.google.co.kr/intl/ko/options/" onclick="gbar.logger.il(1,{t:66});">\xb8\xf0\xb5\xce \xba\xb8\xb1\xe2</a>, <a class="gbgt" href="https://accounts.google.com/ServiceLogin?hl=ko&amp;passive=true&amp;continue=https://www.google.co.kr/search%3Fsite%3D%26tbm%3Disch%26source%3Dhp%26biw%3D1204%26bih%3D673%26q%3Dcars%26oq%3Dcars%26gws_rd%3Dcr%26ei%3DZ6XrWOryEMia8QX7x5aYCg" id="gb_70" onclick="gbar.logger.il(9,{l:'i'})" target="_top"><span class="gbtb2"></span><span class="gbts" id="gbgs4"><span id="gbi4s1">\xb7\xce\xb1\xd7\xc0\xce</span></span></a>, <a aria-haspopup="true" aria-owns="gbd5" class="gbgt" href="http://www.google.co.kr/preferences?hl=ko" id="gbg5" onclick="gbar.tg(event,this)" title="\xbf\xc9\xbc\xc7"><span class="gbtb2"></span><span class="gbts" id="gbgs5"><span id="gbi5"></span></span></a>, <a class="gbmt" href="/preferences?hl=ko">\xb0\xcb\xbb\xf6 \xc8\xaf\xb0\xe6\xbc\xb3\xc1\xa4</a>, <a class="gbmt" href="http://www.google.co.kr/history/optout?hl=ko">\xc0\xa5 \xb1\xe2\xb7\xcf</a>, <a href="/webhp?hl=ko" id="logo" style="background:url(/images/nav_logo229.png) no-repeat 0 -41px;height:37px;width:95px;display:block" title="Go to Google Home"></a>, <a class="_UXb _Jhd _Hhd" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;source=lnms&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQ_AUIBA">\xc0\xfc\xc3\xbc</a>, <a class="_UXb _Jhd" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=vid&amp;source=lnms&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQ_AUIBg">\xb5\xbf\xbf\xb5\xbb\xf3</a>, <a class="_UXb _Jhd" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=nws&amp;source=lnms&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQ_AUIBw">\xb4\xba\xbd\xba</a>, <a class="_UXb _Jhd" href="https://maps.google.co.kr/maps?biw=1204&amp;bih=673&amp;q=cars&amp;gws_rd=cr&amp;um=1&amp;ie=UTF-8&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQ_AUICA">\xc1\xf6\xb5\xb5</a>, <a class="_UXb _Jhd" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=bks&amp;source=lnms&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQ_AUICQ">\xb5\xb5\xbc\xad</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=isz:l&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xc5\xab \xbb\xe7\xc0\xcc\xc1\xee</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=isz:m&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xc1\xdf\xb0\xa3 \xbb\xe7\xc0\xcc\xc1\xee</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=isz:i&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xbe\xc6\xc0\xcc\xc4\xdc</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=ic:color&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xc4\xae\xb6\xf3</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=ic:gray&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xc8\xe6\xb9\xe9</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=ic:trans&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xc5\xf5\xb8\xed</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=itp:face&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xbe\xf3\xb1\xbc</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=itp:photo&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xbb\xe7\xc1\xf8</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=itp:clipart&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xc5\xac\xb8\xb3\xbe\xc6\xc6\xae</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=itp:lineart&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xb6\xf3\xc0\xce\xbe\xc6\xc6\xae</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=itp:animated&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xbe\xd6\xb4\xcf\xb8\xde\xc0\xcc\xbc\xc7</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=qdr:d&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg"> \xc1\xf6\xb3\xad 1\xc0\xcf</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=qdr:w&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg"> \xc1\xf6\xb3\xad 1\xc1\xd6</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=sur:fmc&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xbc\xf6\xc1\xa4 \xc8\xc4 \xc0\xe7\xbb\xe7\xbf\xeb \xb0\xa1\xb4\xc9</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=sur:fc&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xc0\xe7\xbb\xe7\xbf\xeb \xb0\xa1\xb4\xc9</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=sur:fm&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xbc\xf6\xc1\xa4 \xc8\xc4 \xba\xf1\xbb\xf3\xbe\xf7\xc0\xfb \xbf\xeb\xb5\xb5\xb7\xce \xc0\xe7\xbb\xe7\xbf\xeb \xb0\xa1\xb4\xc9</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;source=lnt&amp;tbs=sur:f&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQpwUIDg">\xba\xf1\xbb\xf3\xbe\xf7\xc0\xfb \xbf\xeb\xb5\xb5\xb7\xce \xc0\xe7\xbb\xe7\xbf\xeb \xb0\xa1\xb4\xc9</a>, <a class="q" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;tbas=0&amp;sa=X&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQuAsIDw" style="padding-left:16px">\xb5\xb5\xb1\xb8 \xc3\xca\xb1\xe2\xc8\xad</a>, <a href="/url?q=http://droom.in/car&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IFTAA&amp;usg=AFQjCNFJZ34GAgWZ56WgBxTQ0Jmxq2KoLQ"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="91" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSQdrZhb4NyNuKkLHdO1wT8U51zpsvztBT3X3kW_2EGrowyaBdDkeqW3uA" width="129"/></a>, <a href="/url?q=http://www.caranddriver.com/features/2017-10best-cars-the-best-cars-for-sale-in-america-today-feature&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IFzAB&amp;usg=AFQjCNHBU3fAqKGGBteYiP1eSPI-H4N-uQ"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="89" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQr3frVY4p6BYk0tORsu2le-6pGdFD73JshLUxjWigidyWyjUMkZOFfcQw2" width="145"/></a>, <a href="/url?q=http://www.car.com/&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IGTAC&amp;usg=AFQjCNGW3nkf73r24x8j0Six1FRhC059pw"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="97" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS985vI2ClgxX0vEXZdSMiStWUkeMtkg0IXIjrtRMoY2MGYR_kZy6k56ko" width="146"/></a>, <a href="/url?q=https://www.whichcar.com.au/car-style/12-cartoon-cars&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IGzAD&amp;usg=AFQjCNEVjMqjVC3AB2kuGqZWHDbQxjtezw"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="92" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSVixNz-pL5YOLScxcGMgvp0QyUtB-a4oGtTd-5_7Ytf8GW3_a7XdbhTQVf" width="138"/></a>, <a href="/url?q=https://www.tes.com/lessons/oWgzk4OrhaNTGg/cars-and-games&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IHTAE&amp;usg=AFQjCNFbOZXvvPAP6PxcIdQNjyDEOQxeAg"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="84" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQ8zH6wSHea6FT0cAqVUiDBn5u4E5heQFPvl4DxApkOZdn-LbZseRSb02rF" width="150"/></a>, <a href="/url?q=http://www.caranddriver.com/features/25-cars-worth-waiting-for-20162019-feature&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IHzAF&amp;usg=AFQjCNHCvz_P5ISR63m9DWMlPBlWwrGnzA"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="92" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRIii0QfouEcUjpeQhejnQ9pK6LcgEqWauvAX7yFhZXDQ4e9OYU24PcrmHY" width="150"/></a>, <a href="/url?q=https://pixabay.com/en/photos/cars/&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IITAG&amp;usg=AFQjCNG6uALkSPojRhp7j0a6Kek3RDcftw"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="83" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTZw2B9fsnAwlogi_4OEq_I9-Hv_yQA_M5XAhhCT3IG0fGdqg9LV80-dGIQ" width="148"/></a>, <a href="/url?q=http://www.caranddriver.com/features/2017-editors-choice-for-best-cars-trucks-crossovers-and-suvs&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IIzAH&amp;usg=AFQjCNHLez5RDNIp1CMh6ANfe8k57ejzDw"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="87" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQWrDa3hXOx8yea5Fn45lDzXQFXqCX-qlvT7gHAsDk3LjRt39r6K9i5sBY" width="143"/></a>, <a href="/url?q=https://www.pinterest.com/explore/cars/&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IJTAI&amp;usg=AFQjCNFYwvgJpW9S7Tj3yoxD5QOxSfssnw"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="150" src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQZnu1shU3UB0UoYe1XCUNwh50duFPtYmGPuI6hHzOP1wiicynZaELRsIhA" width="100"/></a>, <a href="/url?q=http://www.businessinsider.com/new-cars-2016-la-auto-show-pictures-2016-11&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IJzAJ&amp;usg=AFQjCNGbI00EPtx2Ln366KRhiF1PeNfsnA"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="113" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRTj7kkhCCesjW7bSkS_bQ4XwBRHgyzUWxlapXv2zPMklJm3tzXrjF5ONPq" width="150"/></a>, <a href="/url?q=https://www.pinterest.com/explore/car-pictures/&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IKTAK&amp;usg=AFQjCNGXGpILFRjefrtxKHoH48d4d1s-9g"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="84" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTz_ikUlL6-erXMyLFkAirt3lA8layg-DoTKAyVF4QElHVw8Upddn9gGpw" width="150"/></a>, <a href="/url?q=https://www.avis.co.za/drive-avis/fleet&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IKzAL&amp;usg=AFQjCNEgN171ioFWaWFl08mwIuKDHSkYzA"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="69" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcR7Dhmz6Fth4uM6TNPN8ZTswwElqhS53ENNB9ykgB3hn9viuC-l3uaIr58" width="142"/></a>, <a href="/url?q=https://www.pexels.com/search/car/&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4ILTAM&amp;usg=AFQjCNE41b5NXnZWZ08z4rQSI0ss396hVg"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="100" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQO4vSCA-MwM6Vp1r-WY1VSVC-zlUDEAAc_eMIBPsmCvakzOY3XzfemNnDF" width="150"/></a>, <a href="/url?q=http://www.autotrader.co.za/&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4ILzAN&amp;usg=AFQjCNFCa-E-Lmvjdu8sTGOwkzIpRx6PqQ"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="46" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQMcOhmOZrTbMEnZE7LnKORwT7QdybnOUCwmq7Op4JDWz3-Jgu3LPB3AvCA" width="149"/></a>, <a href="/url?q=https://www.enterprise.com/en/car-rental/vehicles/us.html&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IMTAO&amp;usg=AFQjCNGmp-_mq9toGDv_g6EKElCnIh5paA"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="107" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRrZQa7YIHJbxbZYpDNv6cRBICOqucSV51g3gDHTB6e6CUn-SD8xN8mZik" width="143"/></a>, <a href="/url?q=http://kingofwallpapers.com/cars.html&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IMzAP&amp;usg=AFQjCNEIsll5cQ__ljEQrlXnhKN0Sy5MZA"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="94" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQEKolof015oYI_P_MButmQAQY4lvdPCFqqUEBl0lV5eq54nSD7VVu3_X4" width="150"/></a>, <a href="/url?q=https://www.pexels.com/photo/car-cars-lamborghini-aventador-luxury-car-63764/&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4INTAQ&amp;usg=AFQjCNE88-oCWsmAeYPEt1_8Cuas65u2IA"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="88" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSzK4-EvkVaqJg1OP_owFMJDpKJzAhWH_ZEHCX5CnDLdh6Qg5b_PMCKSp58" width="150"/></a>, <a href="/url?q=http://wallpaperswide.com/cars-desktop-wallpapers.html&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4INzAR&amp;usg=AFQjCNGIyj5EW6Lh9QTeKDdh13JjpLEAtw"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="94" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTBrhBy0oX1z3eBnLCc13oQLGKctyFbkSIFHt8XgW5fKx01bZySoqFF4IE" width="150"/></a>, <a href="/url?q=https://gearpatrol.com/cars/&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IOTAS&amp;usg=AFQjCNFb5A1Q0IcxyCasVeMqErmzXT9MkQ"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="105" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRqbpIywaSd-3-GLHdG4sXCqec_xKiIK4vvXkS9nkdi_-2H_IHEqSGnaVw4" width="137"/></a>, <a href="/url?q=http://www.caranddriver.com/features/25-cars-worth-waiting-for-20162019-feature&amp;sa=U&amp;ved=0ahUKEwjIoIvsnZrTAhXMi7wKHU8LDFwQwW4IOzAT&amp;usg=AFQjCNHCvz_P5ISR63m9DWMlPBlWwrGnzA"><img alt="cars\xbf\xa1 \xb4\xeb\xc7\xd1 \xc0\xcc\xb9\xcc\xc1\xf6 \xb0\xcb\xbb\xf6\xb0\xe1\xb0\xfa" height="92" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQf_kKvSclRQiW7MCKi6AjqYt-P0Pyed6LlxyRIbCooMNmKerovfpUFkgI" width="150"/></a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=20&amp;sa=N"><span class="csb" style="background-position:-74px 0;width:20px"></span>2</a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=40&amp;sa=N"><span class="csb" style="background-position:-74px 0;width:20px"></span>3</a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=60&amp;sa=N"><span class="csb" style="background-position:-74px 0;width:20px"></span>4</a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=80&amp;sa=N"><span class="csb" style="background-position:-74px 0;width:20px"></span>5</a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=100&amp;sa=N"><span class="csb" style="background-position:-74px 0;width:20px"></span>6</a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=120&amp;sa=N"><span class="csb" style="background-position:-74px 0;width:20px"></span>7</a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=140&amp;sa=N"><span class="csb" style="background-position:-74px 0;width:20px"></span>8</a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=160&amp;sa=N"><span class="csb" style="background-position:-74px 0;width:20px"></span>9</a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=180&amp;sa=N"><span class="csb" style="background-position:-74px 0;width:20px"></span>10</a>, <a class="fl" href="/search?q=cars&amp;biw=1204&amp;bih=673&amp;ie=UTF-8&amp;tbm=isch&amp;ei=m6jrWIjnLsyX8gXPlrDgBQ&amp;start=20&amp;sa=N" style="text-align:left"><span class="csb" style="background-position:-96px 0;width:71px"></span><span style="display:block;margin-left:53px">\xb4\xd9\xc0\xbd</span></a>, <a href="https://www.google.co.kr/advanced_image_search?biw=1204&amp;bih=673&amp;q=cars&amp;gws_rd=cr&amp;tbm=isch">\xb0\xed\xb1\xde\xb0\xcb\xbb\xf6</a>, <a href="https://www.google.co.kr/imghp?hl=ko">Google \xc0\xcc\xb9\xcc\xc1\xf6 \xc8\xa8</a>, <a href="http://images.google.com/support/?hl=ko">\xb5\xb5\xbf\xf2\xb8\xbb</a>, <a href="/tools/feedback/survey/html?productId=196&amp;hl=ko&amp;query=cars">\xc0\xc7\xb0\xdf \xba\xb8\xb3\xbb\xb1\xe2</a>, <a href="/">Google\xa0\xc8\xa8</a>, <a href="/intl/ko/ads">Google \xb1\xa4\xb0\xed \xc7\xc1\xb7\xce\xb1\xd7\xb7\xa5</a>, <a href="/intl/ko/policies/privacy/">\xb0\xb3\xc0\xce\xc1\xa4\xba\xb8\xc3\xb3\xb8\xae\xb9\xe6\xc4\xa7</a>, <a href="/intl/ko/policies/terms/">\xbe\xe0\xb0\xfc</a>, <a href="/intl/ko/about.html">Google \xc1\xa4\xba\xb8</a>]

这是因为该教程很旧(从 2013 年开始),并且 Google Images 的 HTML 从那时起发生了变化。

尝试创建 XPATH/CSS 选择器或 id/class 并使用 Firebug/Firepath 进行调试。

我刚刚查看了源代码,我认为您可以通过 class rg_ic rg_i 选择所有图像。

Link 到原始大小 img 点击后出现。您可以使用selenium来模拟点击。

Steps: 
1. Click on the image,
2. Inspect the image on the right,
3. Scrape src attribute for full-size image.
4. Create a for loop to grab other images.

另一种方法是使用 regex:

解析它
import requests, lxml, re
from bs4 import BeautifulSoup

headers = {
    "User-Agent":
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 Safari/537.36 Edg/79.0.309.43"
}

params = {"q": "london", "tbm": "isch"}

html = requests.get("https://www.google.com/search",
                    params=params,
                    headers=headers).text

soup = BeautifulSoup(html, 'lxml')

# https://regex101.com/r/vO7WsC/5
pattern = re.compile(
    r'\[1,\[0,"(?P<id>[\d\w\-_]+)",\["https?:\/\/(?:[^"]+)",\d+,\d+\]\s?,\["(?P<url>https?:\/\/(?:[^"]+))",\d+,\d+\]'
)

images = dict(pattern.findall(html))

for image_node in soup.select('.BUooTd[data-id]'):
    title = image_node.select_one('.WGvvNb')['title']
    image = images[image_node['data-id']]

    print(f"Title: {title}\nOriginal image: {image}\n")

输出:

Title: London - Wikipedia
Original image: https://upload.wikimedia.org/wikipedia/commons/c/cd/London_Montage_L.jpg

Title: London: A History - HISTORY
Original image: https://www.history.com/.image/ar_1:1%2Cc_fill%2Ccs_srgb%2Cfl_progressive%2Cq_auto:good%2Cw_1200/MTYyNDg1MjE3MTI1Mjc5Mzk4/topic-london-gettyimages-760251843-promo.jpg

Title: City of London - Wikipedia
Original image: https://upload.wikimedia.org/wikipedia/commons/8/86/City_of_London%2C_seen_from_Tower_Bridge.jpg

Title: London - Wikipedia
Original image: https://upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Palace_of_Westminster_from_the_dome_on_Methodist_Central_Hall_%28cropped%29.jpg/1000px-Palace_of_Westminster_from_the_dome_on_Methodist_Central_Hall_%28cropped%29.jpg

或者,您可以使用来自 SerpApi 的 Google Images API 获取原始大小 Google 的图像。这是付费 API 免费试用。

from serpapi import GoogleSearch
import os

params = {
  "engine": "google",
  "ijn": "0",
  "q": "cars",
  "tbm": "isch",
  "api_key": os.getenv("API_KEY"),
}

search = GoogleSearch(params)
results = search.get_dict()

for image in results['images_results']:
  print(f"Title: {image['title']}\nSource: {image['source']}\nOriginal Image: {image['original']}\n")

全部输出的一部分:

Title: Best Opening Races From Pixar's Cars! | Pixar Cars - YouTube
Source: youtube.com
Original Image: https://i.ytimg.com/vi/L9ZYdShgtPE/maxresdefault.jpg

Title: Cars (film) - Wikipedia
Source: en.wikipedia.org
Original Image: https://upload.wikimedia.org/wikipedia/en/3/34/Cars_2006.jpg

Title: Official Trailer: Cars (2006) - YouTube
Source: youtube.com
Original Image: https://i.ytimg.com/vi/SbXIj2T-_uk/maxresdefault.jpg

Disclaimer, I work for SerpApi.