【问题标题】:PHP Parse images from Google ImagesPHP 解析来自 Google 图片的图片
【发布时间】:2016-04-16 06:56:50
【问题描述】:

这个问题很简单。我可以使用以下代码解析来自 Google 图片网站的图片:

$search_keyword=str_replace(' ','+',$search_keyword);
$newhtml =file_get_html("https://www.google.com/search?q=".$search_keyword."&tbm=isch");
$result_image_source = $newhtml->find('img');
foreach($result_image_source as $div) {
    echo '<img src="'.$div->src.'">';
}

但我只获得加密图像,即我获得了正确的图像,但尺寸非常小。我怎样才能刮掉真实尺寸的图像呢?该代码使用简单的 HTML DOM 解析器在 PHP 中工作。

谢谢

【问题讨论】:

    标签: php html-parsing simple-html-dom


    【解决方案1】:

    为什么不使用 Google Image Search API 来获取漂亮的 JSON 对象中的图像结果而不是抓取它们?

    https://developers.google.com/image-search/v1/jsondevguide?hl=en#json_snippets_php

    【讨论】:

    • 我认为它不再起作用(标记为已弃用)
    • 确实,如果我运行它,我得到了{"responseData": null, "responseDetails": "This API is no longer available.", "responseStatus": 403}
    • 我很快就跟他说话了。当我上次使用已弃用的 API 时,它仍然每天允许 1000 个请求。我想这已经改变了。
    • 是的,我也用过,不过几个月后就被屏蔽了。 :(
    猜你喜欢
    • 1970-01-01
    • 2015-03-26
    • 2020-10-09
    • 2013-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-22
    • 2014-01-03
    相关资源
    最近更新 更多