H
H
Horoko2014-10-22 00:14:32
Java
Horoko, 2014-10-22 00:14:32

How to scrape a link from a page?

There are 5 string constants with addresses url1,url2... and this code

doc = Jsoup.connect(url).get();
                title = doc.select(".even,.odd");

It only parses the text, but how to parse the link itself?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai, 2014-10-22
@Horoko

This call will give the HTML of the first link
title.first().outerHtml();
jsoup.org/cookbook/extracting-data/attributes-text-html
Only doc.select(...) seems to return a collection, I would call the variable titles.

U
UbuRus, 2014-10-22
@UbuRus

title.attr("href");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question