Jump to content

Hey guys. I'm using Jsoup to parse google image results. I'm trying to get the src of the image. Here is my code so far. The output is truncated for some reason and I can't access the src attribute. Does anyone know why this is happening and what I can do to fix it?

 

public static void main(String args[]) {
	try {
		// Does a google image search for "test"
		final Document doc = Jsoup.connect("https://www.google.com/search?q=test&tbm=isch").userAgent(USER_AGENT).get();
			
		// selects images
		Elements elements = doc.select("img.rg_ic.rg_i");
			// cycles through elements and prints attributes
			for (Element e : elements) {
				System.out.print(e);
			}

		
	} catch (IOException e) {
		e.printStackTrace();
	}
}

Outout:
<img class="rg_ic rg_i" data-sz="f" name="XWXPqrX1RFJiaM:" alt="Image result for test" jsaction="load:str.tbn" onload="google.aft&&google.aft(this)">

 

Link to comment
https://linustechtips.com/topic/678240-google-image-parsing/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×