从Python 3中的Google搜索获取原始图片网址(而非缩略图)(在2018年更改之后)

我一直试图从Google图片搜索或至少从其URL下载原始图像。我唯一得到的是缩略图或这些缩略图的URL。我知道Google在Getty投诉后于2018年更改了条款,但是必须有一种方法可以做到这一点。因此,分步进行,而不是手动单击每个图像(1),然后右键单击框(2),然后单击“在新选项卡中打开图像”:

从Python 3中的Google搜索获取原始图片网址(而非缩略图)(在2018年更改之后)

我创建了这个脚本作为基础:

import requests
from bs4 import BeautifulSoup

query = "example9828120.jpg"
url = 'https://www.google.com/search?q='+ query  + '&client=opera&hs=cTQ&source=lnms&tbm=isch&sa=X&ved=0ahUKEwig3LOx4PzKAhWGFywKHZyZAAgQ_AUIBygB&biw=1920&bih=982'

# page = open('tower.html','r').read()
page = requests.get(url).text

soup = BeautifulSoup(page,'html.parser')

for raw_img in soup.find_all('img'):
    link = raw_img.get('src')
    if link:
        print(link)

'''for x in soup.findAll('a'):
    print(x)
    link = x.get('src')
    if link:
        print(link)''';

然后我想到了进一步调查,但似乎原始图片网址与Google图片缩略图之间没有任何联系。我可以看到答案很老了。我想除非您为Google API付费(超过100个请求),否则无法实现这一目标?

另外一种方法是实际抓取此页面生成的JSON:enter link description here

iCMS 回答:从Python 3中的Google搜索获取原始图片网址(而非缩略图)(在2018年更改之后)

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2128632.html

大家都在问