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 8919477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:02:16+00:00 2026-06-15T06:02:16+00:00

Document doc = Jsoup.connect(http://www.utah.edu/).get(); Elements lists = doc.select(ul); for (Element list: lists) { Elements

  • 0
    Document doc = Jsoup.connect("http://www.utah.edu/").get();
    Elements lists = doc.select("ul");
    for (Element list: lists) {
        Elements li = list.select("li a");
        if (li.size() > 0) {
            ArrayList<String> anchors = new ArrayList<String>();
            for (Element e : li) {
                anchors.add(e.text());
            }
            System.out.println(anchors);
        }
    }

I’m trying to grab all html lists rendered by the ul tag from this page. But it failed. I suspect there’s script in the page preventing my program from doing so.

Edit: To make my question even simpler, consider the following code:

Document doc = Jsoup.connect("http://www.utah.edu/").get();
Elements lists = doc.select("ul");
System.out.println(lists.size());

Output:

0
  • 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-06-15T06:02:17+00:00Added an answer on June 15, 2026 at 6:02 am

    A possible answer is that, the User-Agent header sent by jsoup made utah.edu think it’s a bot instead of a browser. So it returns other page content.

    In org/jsoup/helper/HttpConnection.java implemented get(), which doesn’t send User-Agent header by default, unless told otherwise.

    So you need manually set it by using userAgent().

    Example, faking Chrome:

    String ua = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11";
    Document doc = Jsoup.connect("http://www.utah.edu/").userAgent(ua).get();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: String website = http://www.somewebsite.com/; Document doc = Jsoup.connect(website).get(); Elements
Document doc = Jsoup.connect(http://reviews.opentable.com/0938/9/reviews.htm).get(); Element part = doc.body(); Elements parts = part.getElementsByTag(span); String attValue;
Document doc = Jsoup.connect(studentprofiles).get(); Element tables = doc.select(table); Elements myTdsstudent = tables.select(tr td:eq(1)); I
I use Jsoup to post a form like: Document doc = Jsoup.connect(http://www.example.com/post.php) .data(titolo, titolo)
I am using this to get a list of elements from a webpage. http://www.gamespy.com/index/release.html
Given an XML document like this: <!DOCTYPE doc SYSTEM 'http://www.blabla.com/mydoc.dtd'> <author>john</author> <doc> <title>&title;</title> </doc>
package info.testing; import java.io.IOException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.select.Elements; import android.app.Activity; import android.os.Bundle;
I am using a query like this in jSoup: Document doc = Jsoup.connect(urlString).timeout(1000).post(); It
http://www.unc.edu/academics/ I tried to grab all html lists as rendered by ul from the
How to get thumbs document (doc, docx, pdf, pptx, ppt,.....)? May be use C#,

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.