1

I was trying to import (scrape) sets of tables on a news blog post online using xml2's read_html(), hence html.table() and XML::readHTMLTable() functions. I got no table or anything useful with

readHTMLTable("https://www.theabusites.com/197-nuc-approved-universities-in-nigeria-2021/",..., header=TRUE, stringAsFactor=FALSE) 

#Note: not CSV or html tag. It returns ? unable to find the inherited method for the function 'readHTMLTable' for signature " NULL"', also <XML contents does not seem to be XML.> What can I do? Also, rvest, too, returns the error flag, "Error in open.connection(x, "rb") : Couldn't connect to server" - What is causing this error message? Thanks in advance

7
  • 1
    Are you trying to scrape a web page as XML? That might be problematic. But without details of both your code and your input data, it's going to be difficult to help you... Commented Oct 10, 2021 at 18:07
  • 1
    The code in the duplicate question seems to do the trick ; library(xml2) ; library(rvest) url <- "https://www.theabusites.com/197-nuc-approved-universities-in-nigeria-2021/" ; page <- read_html(url) ; tables <- html_table(page, fill = TRUE) Commented Oct 10, 2021 at 20:03
  • @Limey, right. I was trying to scrape a web page and it contains multiple tables. Commented Oct 12, 2021 at 9:25
  • Thank you @User20650, the trick didn't actually work and it warned that "no XML content found". I had to save the html page into my local computer, C: and read it from there. Thank you. It's really problematics scraping directly from online source - many adverts, menu tab address and empty tables were what I got. Commented Oct 12, 2021 at 9:35
  • 1
    Thanks @user20650, it works pretty well. I looked into the network, and re-run on another PC, a laptop. I got all the tables. I also use nuc.data<- url("theabusites.com/197-nuc-approved-universities-in-nigeria-2021", " rb"); page<-read_html(nuc.data); page. Thanks so much Commented Oct 12, 2021 at 15:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.