Quantcast
Channel: Scraping XML with JSoup - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Scraping XML with JSoup

$
0
0

I'm trying to scrape an RSS feed located here.

At the moment I'm just trying to wrap my head around JSoup, so the following code is merely proof of concept (or an attempt at it, at least).

    public static void grabShakers(String url) throws IOException {    doc = Jsoup.connect(url).get();    desc = doc.select("title");    links = doc.select("link");    price = doc.select("span.price");}

It grabs the title of each item perfectly. The output of each link is simply ten repeated closing link tags and it never finds any prices. I thought perhaps the CDATA was the issue, so I converted doc to html, stripped out the comments using .replace, and then converted it back to a Document for parsing to no avail. Any insight would be greatly appreciated.

The following code is what I'm using to print out each element:

for (Element src : price) {        System.out.println(src);    }

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images