如何在curl中通过图像使用谷歌搜索 [英] How to use google search by image in curl

查看:123
本文介绍了如何在curl中通过图像使用谷歌搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功完成了以下操作:

I successfully do it with following:

<html>
<body>
<form action="https://www.google.com/searchbyimage/upload" METHOD="POST" enctype="multipart/form-data">
  <input type="file" name="encoded_image">
  <input type="Submit" name="sch" value="sch">
</form>
</body>
</html>

当我选择〜/ Dropbox / img / green.jpg并单击 sch时,它会自动重定向到正确的Google结果

when i select ~/Dropbox/img/green.jpg, and click "sch", it auto redirect to correct google result

但是当我使用以下命令:

but when i use following:

curl -i -F name=green.jpg -F filedata=@/home/roroco/Dropbox/img/green.jpg https://www.google.com/searchbyimage/upload

google结果显示:

the google result show:

我希望按卷曲的图像进行搜索

I hope search by image in curl how to do it?

推荐答案

您的表单名称与google图像搜索所寻找的值不匹配。您的工作测试HTML文件正在 encoded_image 中提交文件,还从输入按钮中提供了 sch ,但是您在curl命令中重新提交 filedata 中的文件和名称中的文件。

Your form names don't match the values google image search is looking for. Your working test HTML file is submitting the file in encoded_image and is also providing sch from the input button, but you're submitting the file in filedata and a name in your curl command.

这对我来说是本地工作:

This is what worked for me locally:

curl -i -F sch = sch -F encode_image=@path/to/my/imagefile.jpg https://www.google.com/searchbyimage/upload

curl -i -F sch=sch -F encoded_image=@path/to/my/imagefile.jpg https://www.google.com/searchbyimage/upload

它也可以在不提供 sch 的情况下工作,但我保持它与您的原始格式一致。

It also works without providing sch but I kept it to be consistent with your original form.

这篇关于如何在curl中通过图像使用谷歌搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆