简体   繁体   中英

How to get image URL-s from Google image search

I need a simple method that helps me search images @Google, and I can extract URL with. I only need the first 20 images, and I don't need to visualize it, only get urls. I need a short code if possible.

This is a general question, you should try first something by yourself, and afterwards ask again if you have any problem.

The Google Image Search API offers access through a RESTful interface, as described here , on the API reference page.

You can use a class to make the request (dunno exactly which in C #) and a JSON library to parse the results.

You could use a html parser like SimpleHTMLDomParser to return all links within the page.

// Create DOM from URL or file
$html = file_get_html('http://www.google.com/');

// Find all links 
foreach($html->find('a') as $element) 
       echo $element->href . '<br>';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM