HTML表ID和类ID

扫码查看
本文介绍了HTML表ID和类ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在以下网址中找到大表的表ID: http://en .wikipedia.org/wiki/States_and_territories_of_India

How can I find the Table id of the large table on in the following url: http://en.wikipedia.org/wiki/States_and_territories_of_India

我能够看到wikitable sortable jquery-tablesorter

此表具有印度各州的列表.我可以从Firebug确认此表= wikitable sortable jquery-tablesorter具有状态列表.如何获取该表的ID?

This is the table which has list of states in India. I was able confirm from firebug that this table = wikitable sortable jquery-tablesorter is having the list of states. How can I get the ID of that table?

获取该表中所有名称的CSS等效项是什么?

What is the CSS equivalent to get all the names in that table?

我只想获取状态...第一列.我正在使用 jsoup .

I want to get only the states... the first column. I am using jsoup.

推荐答案

该表上没有ID.如果要获取具有"wikitable"类的表的内容.将此代码与 Jsoup 一起使用

There is no ID on that table. If you want to get the content of the table which has the class "wikitable". Use Jsoup with this code

package com.main;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class Main {
    public static void main (String args[]){
        Document doc;
        try {

            doc = Jsoup.connect("http://en.wikipedia.org/wiki/States_and_territories_of_India").get();
            Elements newsHeadlines = doc.select("table.wikitable").get(0).select("td:eq(0) a");

            System.out.println(newsHeadlines.html());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}

这篇关于HTML表ID和类ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:09
查看更多