如何模拟浏览器使用谷歌的图片搜索

Zebulon 2014-03-19 06:47:30
使用谷歌图片搜索的url 是这样的的:
https://www.google.com.hk/search?um=1&newwindow=1&safe=strict&biw=1366&bih=624&hl=zh-CN&tbm=isch&sa=1&q=michael+jordan&oq=micheal+&gs_l=img.1.1.0j0i10l4.8923.14151.0.15946.9.9.0.0.0.0.85.329.9.9.0....0...1c.1j4.37.img..3.6.194.B3YpKj-3zlc

后面的gs_l =XXX的什么意思
好像去掉了之后可以进行搜索

然后用这个url在程序中跑的时候,无法得到搜索的页面,给出的错误是:
302 Moved

The document has movedhere.

求问解决办法
已经没有分了。。。求大神相助
...全文
288 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
骑士1992 2014-05-17
  • 打赏
  • 举报
回复
同问楼主解决了吗?遇上了同样的问题,谷歌提供的api有图片数量限制。
Zebulon 2014-03-25
  • 打赏
  • 举报
回复
感谢 但是谷歌好像有个限制 是只能获取4×8张搜索结果 有办法获得更多的吗?
QQ2472322319 2014-03-19
  • 打赏
  • 举报
回复
Using Java The following code snippet shows how to make a request to the Google Image Search API using Java. This example uses the JSON library from json.org.

URL url = new URL("https://ajax.googleapis.com/ajax/services/search/images?" +
                  "v=1.0&q=barack%20obama&userip=INSERT-USER-IP");
URLConnection connection = url.openConnection();
connection.addRequestProperty("Referer", /* Enter the URL of your site here */);

String line;
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while((line = reader.readLine()) != null) {
 builder.append(line);
}

JSONObject json = new JSONObject(builder.toString());
// now have some fun with the results...
QQ2472322319 2014-03-19
  • 打赏
  • 举报
回复
google图片搜索api https://developers.google.com/image-search/v1/jsondevguide?csw=1 好好看 我想这才是你需要的

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧