Google 웹 이미지에서 반환 한 결과를 크롤링하고 싶습니다. Google에서 제공하는 도구가 있습니까? 다양한 주제에 대한 교육 사례가 필요한 객체 인식 시스템을 구축하고 있습니다.Google 웹 이미지를 크롤링하는 방법
답변
구글이 자신의 검색 API되지 않는 것처럼이, 당신에게 도움이 될 수 있습니다
구글 맞춤 검색 웹 사이트 또는 웹 사이트의 수집을 통해 검색 할 수 있습니다. 귀하의 필요와 관심 분야에 맞는 검색 엔진을 생성하고 귀하의 웹 사이트에 검색 결과를 표시하려면 Google의 힘을 이용하십시오. 사용자 지정 검색 엔진은 지정한 웹 사이트를 기반으로 검색 결과에 우선 순위를 부여하거나 제한 할 수 있습니다 ( ).
이에 대한 구글의 이미지 API를 사용할 수 있습니다.
예 :
$url = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=stackoverflow";
// sendRequest
// note how referer is set manually
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, /* Enter the URL of your site here */);
$body = curl_exec($ch);
curl_close($ch);
// now, process the JSON string
$json = json_decode($body);
// now have some fun with the results...
더 많은 정보 : 당신이 이미지 API 페이지의 상단으로 스크롤하면 https://developers.google.com/image-search/v1/jsondevguide#json_snippets_php
해당 페이지의 맨 위로 스크롤하면 더 이상 사용되지 않습니다. –
더 이상 사용되지 않는 것은 아닙니다 ... 나를 위해, 코드는 매우 잘 작동합니다. – Julien
"Google 이미지 검색 API는 2011 년 5 월 26 일부터 공식적으로 지원 중단 될 예정입니다. Google의 지원 중단 정책에 따라 계속 작동하지만 하루에 요청할 수있는 요청 수가 제한 될 수 있습니다. 이제 이미지 검색을 지원하는 맞춤 검색 API로 업그레이드하는 것이 좋습니다. " - Google https://developers.google.com/image-search/ –
package GoogleImageDownload;
import java.io.*
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import org.w3c.dom.*
public class HttpURLConnectionExample {
private final String USER_AGENT = "Chrome/44.0.2403.157";
public static void main(String[] args) throws Exception {
HttpURLConnectionExample http = new HttpURLConnectionExample();
System.out.println("Testing 1 - Send Http GET request");
String url = "https://www.google.co.in/search?tbm=isch&q=test";
http.sendGet(url);
System.out.println("\nTesting 2 - Send Http POST request");
//http.sendPost();
}
// HTTP GET request
private void sendGet(String url) throws Exception {
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
// optional default is GET
con.setRequestMethod("GET");
//add request header
con.setRequestProperty("User-Agent", USER_AGENT);
int responseCode = con.getResponseCode();
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//print result
String Html2Xml = light_html2xml.Html2Xml(response.toString());
Document convertStringToDocument = DocumentObjectClass.convertStringToDocument(Html2Xml);
NodeList Images = convertStringToDocument.getElementsByTagName("img");
for(int i = 0;i<Images.getLength();i++)
{
Node node= Images.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE)
{ Element elem = (Element) node;
if(Integer.parseInt(elem.getAttribute("height").replace("px", ""))>10&&Integer.parseInt(elem.getAttribute("width").replace("px", ""))>10)
{
System.out.println(elem.getAttribute("src"));
try{
saveImage(elem.getAttribute("src"),String.valueOf(i));
}
catch(Exception e){System.err.println(e.getMessage());}
}
}
}
NodeList href = convertStringToDocument.getElementsByTagName("a");
for(int i = 0;i<href.getLength();i++)
{
Node node= href.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE)
{ Element elem = (Element) node;
if(elem.getAttribute("href")!=null)
{
try{
sendGet(elem.getAttribute("href")); }
catch(Exception e){System.err.println(e.getMessage());}
}
}
}
}
public static void saveImage(String imageUrl,String name) throws IOException {
URL url = new URL(imageUrl);
String fileName = url.getFile();
String destName = new File(".").getAbsolutePath()+"/"+name+".jpg";
System.out.println(destName);
OutputStream os;
try (InputStream is = url.openStream()) {
os = new FileOutputStream(destName);
byte[] b = new byte[2048];
int length;
while ((length = is.read(b)) != -1) {
os.write(b, 0, length);
} }
os.close();
}
}
- 1. Nutch에서 이미지를 크롤링하는 방법?
- 2. 쿠키로 크롤링하는 Google
- 3. 소스를 크롤링하는 방법 내 웹 크롤링
- 4. 방법 - Google에서 비공개 페이지를 크롤링하는 방법
- 5. Wordpress 블로그를 크롤링하는 방법?
- 6. 웹 페이지를 크롤링하는 방법은 무엇입니까?
- 7. 검색 엔진 Bots가 크롤링하는 방법?
- 8. 모든 WordPress 페이지를 크롤링하는 방법
- 9. Nutch에서 HTML 만 크롤링하는 방법?
- 10. 이 유형의 URL을 크롤링하는 방법
- 11. 인덱스 페이지 정보를 기반으로 웹 페이지를 크롤링하는 방법
- 12. 크롤링하는 동안 (텍스트 만) 웹 사이트를 구문 분석하는 방법
- 13. 인증을 사용하여 웹 사이트를 크롤링하는 크롤러
- 14. 검색 엔진이 웹 사이트를 크롤링하는 방법은 무엇입니까?
- 15. 말미잘이있는 하위 폴더 만 크롤링하는 방법
- 16. PHP를 사용하여 양식 데이터를 크롤링하는 방법
- 17. 전체 위키 피 디아를 크롤링하는 방법?
- 18. Google 이미지를 가져 오는 방법
- 19. OAuth 인증없이 트위터 짹짹 정보를 크롤링하는 방법?
- 20. childID가 주어진 경우 회사 구조를 크롤링하는 방법
- 21. Nutch를 사용하여 hbase에서 데이터를 크롤링하는 방법
- 22. wget : 상점 (#) 문자로 URL을 크롤링하는 방법
- 23. Amazon을 크롤링하는 것이 합법적입니까?
- 24. 웹 서버에 이미지를 추가하는 방법
- 25. 웹 페이지에 이미지를 표시하는 방법
- 26. 웹 서버에 이미지를 게시하는 방법
- 27. 웹 페이지의 이미지를 확대하는 방법
- 28. Google App Engine의 엔티티와 이미지를 연결하는 방법
- 29. Google 이미지 검색에서 1000 이미지를 다운로드하는 방법
- 30. Google 정적지도 API에서 이미지를 가져 오는 방법
, 당신이 사용되지 않습니다 것을 볼 수 있습니다. –