我们如何使用 R 中的 Rcrawler 从子域中提取信息?
How can we extract information from subdomain using Rcrawler in R?
我想使用 main URL 从子域中提取网页内容。
我试过使用 Rcrawler
library(Rcrawler)
Rcrawler(Website = "http://www.xbyte-technolabs.com/", no_cores = 4, no_conn = 4, ExtractCSSPat = c(".address"))
在 运行 这段代码之后,我得到了 INDEX 默认变量,我们可以看到所有 URL 的网站。有一个URL“http://xbyte-technolabs.com/contact_us.php”我想从中提取联系方式。
现在有人可以指导我如何使用 R 中的 Rcrawler 从主要 URL“http://xbyte-technolabs.com/”转到这个特定的 URL
library(Rcrawler)
Rcrawler("http://www.xbyte-technolabs.com/",no_cores = 4,no_conn = 4)
for (i in length(INDEX)) {
for (j in nrow(INDEX)) {
Rcrawler(Website = INDEX[[i]][j], no_cores = 4, no_conn = 4, ExtractCSSPat = c(".address"))
}
}
#Rcrawler(Website = INDEX[[i]][23], no_cores = 4, no_conn = 4, ExtractCSSPat = c(".address"))
class(DATA)
head(DATA)
ad <- DATA[[1]]
ad <- as.character(ad)
cat(ad)
抱歉,我认为这段代码有问题
任何人都收到以下错误:
strsplit(gsub("http://|https://|www\.", "", 网站), "/") 出错[[c(1, :
下标越界
library(Rcrawler)
Rcrawler(Website = "http://www.xbyte-technolabs.com/", no_cores = 1, no_conn = 1, ExtractCSSPat = c(".address"))
pageid <- as.numeric(INDEX$Id[INDEX$Url == 'http://xbyte-technolabs.com/contact_us.php'])
DATA[pageid]
根据?Rcrawler
,Rcrawler创建了两个全局变量
INDEX: A data frame in global environement representing the
generic URL index,including the list of fetched URLs and page
details (contenttype,HTTP state, number of out-links and in-links,
encoding type, and level), and
DATA: A list of lists in global environement holding scraped
contents.
INDEX中的Id变量,对应DATA中的列表元素。上面的代码片段查找与您感兴趣的 url 对应的 Id。
旁注:既然您知道要查找的 URL,那么爬遍整个网站似乎有点矫枉过正。
我想使用 main URL 从子域中提取网页内容。
我试过使用 Rcrawler
library(Rcrawler)
Rcrawler(Website = "http://www.xbyte-technolabs.com/", no_cores = 4, no_conn = 4, ExtractCSSPat = c(".address"))
在 运行 这段代码之后,我得到了 INDEX 默认变量,我们可以看到所有 URL 的网站。有一个URL“http://xbyte-technolabs.com/contact_us.php”我想从中提取联系方式。
现在有人可以指导我如何使用 R 中的 Rcrawler 从主要 URL“http://xbyte-technolabs.com/”转到这个特定的 URL
library(Rcrawler)
Rcrawler("http://www.xbyte-technolabs.com/",no_cores = 4,no_conn = 4)
for (i in length(INDEX)) {
for (j in nrow(INDEX)) {
Rcrawler(Website = INDEX[[i]][j], no_cores = 4, no_conn = 4, ExtractCSSPat = c(".address"))
}
}
#Rcrawler(Website = INDEX[[i]][23], no_cores = 4, no_conn = 4, ExtractCSSPat = c(".address"))
class(DATA)
head(DATA)
ad <- DATA[[1]]
ad <- as.character(ad)
cat(ad)
抱歉,我认为这段代码有问题 任何人都收到以下错误:
strsplit(gsub("http://|https://|www\.", "", 网站), "/") 出错[[c(1, : 下标越界
library(Rcrawler)
Rcrawler(Website = "http://www.xbyte-technolabs.com/", no_cores = 1, no_conn = 1, ExtractCSSPat = c(".address"))
pageid <- as.numeric(INDEX$Id[INDEX$Url == 'http://xbyte-technolabs.com/contact_us.php'])
DATA[pageid]
根据?Rcrawler
,Rcrawler创建了两个全局变量
INDEX: A data frame in global environement representing the generic URL index,including the list of fetched URLs and page details (contenttype,HTTP state, number of out-links and in-links, encoding type, and level), and
DATA: A list of lists in global environement holding scraped contents.
INDEX中的Id变量,对应DATA中的列表元素。上面的代码片段查找与您感兴趣的 url 对应的 Id。
旁注:既然您知道要查找的 URL,那么爬遍整个网站似乎有点矫枉过正。