r-抓取HTML属性rvest的名称



我正试图用rvest抓取一个招聘网站(https://www.stepstone.de/5/ergebnisliste.html?stf=freeText&ns=1&qs=%5B%5D&companyID=0&cityID=0&sourceOfTheSearchField=主页mex%3常规&searchOrigin=主页_top-search&ke=建筑+信息+建模&ws=&ra=30(。

我想提取职位发布的创建日期(2020-12-07T02:13:28+01:00(,可以在这里找到:

<time class="" datetime="2020-12-07T02:13:28+01:00" timeago-id="17">vor 1 Woche</time>

然而,我只知道招聘启事是在几天前创建的,例如vor 1 Woche(1周前(。我的代码如下:

url = "https://www.stepstone.de/5/ergebnisliste.html?stf=freeText&ns=1&qs=%5B%5D&companyID=0&cityID=0&sourceOfTheSearchField=homepagemex%3Ageneral&searchOrigin=Homepage_top-search&ke=building+information+modeliing&ws=&ra=30"
read_html(url) %>%
html_nodes('time') %>% 
html_text()

乐于助人!非常感谢。

首先,"日期时间";是一个属性,因此您需要尝试利用html_attr或html_attrs。

其次,更重要的是,我在您的任何节点中都没有看到日期时间(只有类(。你确定这是这个网站上所有时间节点的属性吗?

> library(rvest)
> 
> url = "https://www.stepstone.de/5/ergebnisliste.html?stf=freeText&ns=1&qs=%5B%5D&companyID=0&cityID=0&sourceOfTheSearchField=homepagemex%3Ageneral&searchOrigin=Homepage_top-search&ke=building+information+modeliing&ws=&ra=30"
> test = read_html(url) %>%
+   html_nodes('time')
> 
> test
{xml_nodeset (25)}
[1] <time class="">vor 1 Woche</time>
[2] <time class="">vor 1 Woche</time>
[3] <time class="">vor 2 Tagen</time>
[4] <time class="">vor 1 Woche</time>
[5] <time class="">vor 6 Tagen</time>
[6] <time class="">vor 12 Stunden</time>
[7] <time class="">vor 18 Stunden</time>
[8] <time class="">vor 23 Stunden</time>
[9] <time class="">vor 1 Woche</time>
[10] <time class="">vor 1 Tag</time>
[11] <time class="">vor 2 Tagen</time>
[12] <time class="">vor 1 Tag</time>
[13] <time class="">vor 6 Tagen</time>
[14] <time class="">vor 2 Tagen</time>
[15] <time class="">vor 2 Tagen</time>
[16] <time class="">vor 2 Tagen</time>
[17] <time class="">vor 2 Tagen</time>
[18] <time class="">vor 6 Tagen</time>
[19] <time class="">vor 1 Woche</time>
[20] <time class="">vor 1 Woche</time>

最新更新