'How do I webscrape a table from neurosynth with R?

I am trying to webscrape some table data from neurosynth to do with fmri data. https://www.neurosynth.org/locations/2_2_2_6/ (it doesn't matter about what data for now. I just want to be able to get data from the table on associations section of locations page)

I have managed to webscrape a simple wikipedia page using the following code:

          url = 
"https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population"
          read_html(url) %>%
            html_element("table") %>%
            html_table() %>%
           

worked absolutely fine no problem. I try the same thing with my neurosynth data, i.e.:

             neurosynth_link = "https://www.neurosynth.org/locations/2_2_2_6/"
             read_html(neurosynth) %>%
               html_element("table") %>%
               html_table() 

I get:

# A tibble: 0 × 4 
# … with 4 variables: Title <lgl>, Authors <lgl>, Journal <lgl>, Activations 
<lgl>

Doesn't work.

I have played around a bit and have managed to get the headings of the table that i want (z-score, posterior prob, etc.) with the following code:

neurosynth_link = "https://www.neurosynth.org/locations/2_2_2_6/"
neurosynth_page = read_html(neurosynth)
neuro_synth_table = neurosynth_page %>% html_nodes("table#location_analyses_table")  
 %>%
 html_table() 
neuro_synth_table

[[1]]
# A tibble: 1 × 5
 ``    `Individual voxel` `Individual voxel` `Seed-based network` `Seed-based 
network`    
<chr> <chr>              <chr>              <chr>                <chr>                   
 1 Name  z-score            Posterior prob.    Func. conn. (r)      Meta-analytic 
coact. (r)

But that's as far as I can get. What's going on?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source