通过了解 R 中的 CSS 类来抓取嵌入式交互式地图的细节 [英] scraping details of embedded interactive map by knowing their CSS class in R

查看:31
本文介绍了通过了解 R 中的 CSS 类来抓取嵌入式交互式地图的细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在这个

所以,我使用 rvest 来提取数据如下:

webhtml <- read_html(网页)webnod <- html_nodes(webhtml, 'div.infodetail')

但即使在尝试 infodetail.infodetail 时,我也得到一个空列表.

如何找到 html_nodes 的确切类或参数?这个类是否从所有标记中提取信息?

解决方案

您应该将请求发送到不同的 URL,该 URL 获取嵌入在节点中的信息.

例如,您应该向此 URL 发送获取请求:http://www.farabillboard.com/board/GetBoardMapInfo/boardid/6299
您可以获得所需的信息.

I am going to scrape data from the map in this link first I scraped all lat-long of all of the markers in the map, but I cant catch other information of markers. In the inspection of this webpage I find the class of needed data is "infodetail" like this picture:

so, I used rvest to extract the data as below:

webhtml <- read_html(webpage) webnod <- html_nodes(webhtml, 'div.infodetail')

but I get an empty list even when trying infodetail or .infodetail.

how can I find exact class or argument for html_nodes? does this class extract information from all markers?

解决方案

You should send the request to a different URL which fetches the information embedded in the node.

For example, you should send get request to this URL: http://www.farabillboard.com/board/GetBoardMapInfo/boardid/6299
And you can get the information you need.

这篇关于通过了解 R 中的 CSS 类来抓取嵌入式交互式地图的细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆