Using the Custom Search API (REST JSON) to search for square images

↘锁芯ラ 提交于 2020-01-05 03:51:08

问题


I'm using Google's JSON Custom Search API for a project that involves creating profiles for professional football/soccer players. If I search any player with Google Images regularly and search in a "Player name, Current team" format with the Search Tools set to Type->Face and Advanced Search set to aspect ratio->Square, then I typically get a perfect "profile" headshot as the first result. This would be ideal for the project, as every image has to be square.

Using the aforementioned API, I can do all of this except for the square restriction. I can use a parameter to search for face images and obviously I can set the query. But I cannot find any kind of parameter that would allow me to specify an aspect ratio or even custom sizes. There is a parameter for square image results when I just search with a browser, but it does not produce the same result when using the API.

Is there any possible way to search for just square images? Maybe some other kind of image search API would be more applicable here, it just has to be large enough to have sports-related images from 1992-present, but mostly stuff from 2000+ anyway, so that shouldn't be too much of a problem.


回答1:


Aspect Ratio parameter for google image search is iar

tbs=iar:xw (panaromic)
tbs=iar:s  (square)
tbs=iar:t  (Tall)


来源:https://stackoverflow.com/questions/13946868/using-the-custom-search-api-rest-json-to-search-for-square-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!