asas
asas

Reputation: 135

java read a web page using url

how to read next page of the same URL

the URL of the page contain many pages i read the first page using

URL(url).openStream()

but it just reading the first page

for example this site i read the first page how can i read the second culture.gov.uk/news/news_stories/6832.aspx

Upvotes: 0

Views: 1344

Answers (2)

Jigar Joshi
Jigar Joshi

Reputation: 240860

Next page will have some link.

You can parse HTML and collect all the links and then you can filter out which is the next link for this page and then read it same way.

Here is the example that will list all the links from given page. - using JSOUP

Note: It is certainly ill-legal to do this for some sites.

Upvotes: 1

Bozho
Bozho

Reputation: 597016

You will need the URL scheme for paging. For example it can be url + "?page=" + page. It depends on the site. Note that scraping is not always legal.

Upvotes: 0

Related Questions