I'm a beginner in web scraping using R. I'm trying to scrape the following webpage: https://bkmea.com/bkmea-members/#/company/2523.
I would like to get all text elements under div nodes with class="company_name", as well as text elements under td nodes. For example, I'm trying to fetch the company name ("MOMO APPARELS") as in the following HTML text.
<div class="comapny_header">
<div class="company_name">MOMO APPARELS LTD</div>
<div class="view_all">View All</div>
</div>
So I've written the following code:
library(textreadr)
library(rvest)
companyinfo <- read_html("https://bkmea.com/bkmea-members/#/company/2523")
html_nodes(companyinfo,"div")%>%
html_text() # it works
html_nodes(companyinfo,"div.company_name")%>%
html_text() # doesn't work
html_nodes(companyinfo,"td") %>%
html_text() # doesn't work
If I understand correctly - the first one should pull up texts with div nodes.
The second one should pull up texts within div nodes with attributes equal to company_name.
The third one should pull up texts within td nodes.
The first one works (which isn't what I'm trying to get) but the second and the third ones don't - am I doing something terribly wrong?
I'd really appreciate it if you could help me out here!!
Many thanks, Sang