I'm very new to R, but trying to create a webscraper to help inspire my team.
The site I want to scrape is https://www.parl.ca/legisinfo/Home.aspx?Page=1 . If you visit that site it will push you to a site where the 43 session is selected by default but I want to include all sessions. If you deselect the session the site sends you to the URL above.
My problem is finding the last page. By clicking >> at the bottom of the page, I know there are 328 pages in total. I want the code to remain relevant so I want the code to find the last page number so I can build a list. I don't know how to do that when the number for "last page" isn't actually in the page text. The code below, returns ">>" instead of "328."
url <- 'https://www.parl.ca/legisinfo/Home.aspx?Page=1'
url %>%
read_html()%>%
html_nodes('.resultPageCurrent') %>%
html_text() %>%
tail(1L)
When I look at the source code I do find the magic 328 number, I just don't know how to point to it. Thank you for your help!