Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 从网页中提取餐厅名称_R_Web Scraping - Fatal编程技术网

R 从网页中提取餐厅名称

R 从网页中提取餐厅名称,r,web-scraping,R,Web Scraping,我只能通过以下命令获得第一家餐厅的名称,即“toit”: install.packages("rvest") library(rvest) url <- html("https://www.zomato.com/bangalore/restaurants?page=1") url %>% html_node("li a.result-title") %>% html_text() install.packages(“rvest”) 图书馆(rvest) url%html\u节

我只能通过以下命令获得第一家餐厅的名称,即“toit”:

install.packages("rvest")
library(rvest)
url <- html("https://www.zomato.com/bangalore/restaurants?page=1")
url %>% html_node("li a.result-title") %>% html_text()
install.packages(“rvest”)
图书馆(rvest)
url%html\u节点(“li a.result-title”)%%>%html\u文本()

如何调整此设置以从网页中提取所有餐厅名称?

您需要使用
html\u节点
,而不是
html\u节点

    url %>% html_nodes("li a.result-title") %>% html_text()

 [1] "Toit "                              "Truffles "                          "Church Street Social "             
 [4] "AB's - Absolute Barbecues "         "Onesta "                            "The Black Pearl "                  
 [7] "The Hole in the Wall Cafe "         "Arbor Brewing Company "             "Big Brewsky "                      
[10] "Chutney Chang "                     "Soho St. "                          "Glen's Bakehouse "                 
[13] "Fenny's Lounge And Kitchen "        "SodaBottleOpenerWala "              "The Black Rabbit "                 
[16] "High Ultra Lounge "                 "Prost Brew Pub "                    "LOFT38 "                           
[19] "Windmills Craftworks "              "Smoke House Deli "                  "Tim Tai "                          
[22] "Vapour Pub & Brewery "              "Big Pitcher "                       "Punjab Grill "                     
[25] "Brewsky "                           "Hard Rock Cafe "                    "The Boozy Griffin "                
[28] "The Glass House - Deli Bistro Bar " "The Fatty Bao - Asian Gastro Bar "  "Monkey Bar "       

这个问题违反了网站的X.29。任何人的帮助也违反了ToC的规定。