Andrew
Andrew

Reputation: 195

Scraping Names with Rvest

I am trying to scrape the names from the following webpage: http://www.infogo.gov.on.ca/infogo/#orgProfile/4151/en

This is the code I have used

library(rvest)
rod_phillips<-html('http://www.infogo.gov.on.ca/infogo/#orgProfile/4151/en')
Rod_phillips %>%
+ html_node("#employees .small") %>%
+ html_text()

But, when I type in this code, I just get

[1] NA.

Any advice?

Upvotes: 0

Views: 44

Answers (1)

Mislav
Mislav

Reputation: 1563

Try this:

rod_phillips <- jsonlite::fromJSON("http://www.infogo.gov.on.ca/infogo/v1/organizations/get?orgId=4151&_=1568919026581")
postions <- rod_phillips$positions

Short explanation:

I opened chrome, click F12 key, and than network. Than I paste your url to url tab. After you click enter, you can track what's happening in the network. You are mostly interested in XHR part. There you can see the site is sending GET requests to the server with with aplication/json response.

This is a laic explanation (I don't know much about networks).

Upvotes: 2

Related Questions