Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7496071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:27:58+00:00 2026-05-29T18:27:58+00:00

I am trying to search all image tags on a specific page. An example

  • 0

I am trying to search all image tags on a specific page. An example page would be http://www.chapitre.com

I am using the following code to search for all images on the page:

HtmlPage page = HTMLParser.parseHtml(webResponse, webClient.openWindow(null,"testwindow"));
List<?> imageList = page.getByXPath("//img");
ListIterator li = imageList.listIterator();

while (li.hasNext() ) {
    HtmlImage image = (HtmlImage)li.next();
    URL url = new URL(image.getSrcAttribute());

    //For now, only load 1X1 pixels
    if (image.getHeightAttribute().equals("1") && image.getWidthAttribute().equals("1")) {
System.out.println("This is an image: " + url + " from page " + webRequest.getUrl() );
}

}

This doesn’t return me all the image tags in the page. For example, an image tag with attributes “src=”http://ace-lb.advertising.com/site=703223/mnum=1516/bins=1/rich=0/logs=0/betr=A2099=%5B+%5DLP2&#8243; width=”1″ height=”1″” should be captured, but its not. Am I doing something wrong here?

Any help is really appreciated.

Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:28:06+00:00Added an answer on May 29, 2026 at 6:28 pm

    That’s because

    URL url = new URL(image.getSrcAttribute());
    

    Is throwing you an exception 🙂

    Try this code:

    public Main() throws Exception {
        WebClient webClient = new WebClient();
        webClient.setJavaScriptEnabled(false);
        HtmlPage page = webClient.getPage("http://www.chapitre.com");
        List<HtmlImage> imageList = (List<HtmlImage>) page.getByXPath("//img");
        for (HtmlImage image : imageList) {
            try {
                new URL(image.getSrcAttribute());
                if (image.getHeightAttribute().equals("1") && image.getWidthAttribute().equals("1")) {
                    System.out.println(image.getSrcAttribute());
                }
            } catch (Exception e) {
                System.out.println("You didn't see this comming :)");
            }
        }
    }
    

    You can even get those 1×1 pixel images by xpath.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Google Image Search API, and largely copied this code, which builds
I'm trying to do a search for all image files more than X by
I'm trying to search using the windows search one of my web directories for
I'm using windbg (the latest available from the MSDN download page). I'm trying to
I am trying to put an image on the left side of the search
I'm trying to search the SRC of a set of images then return all
I'm trying to search the SRC of a set of images then return all
I'm trying to figure something out. This is the code I'm using to hide
I am trying to add an image to the top of every page on
I am trying to make filter search for all questions in my database. Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.