0
我試圖從http://www.childrenshospital.org/directory?state=%7B%22showLandingContent%22%3Afalse%2C%22model%22%3A%7B%22search_specialist%22%3Afalse%2C%22search_type%22%3A%5B%22directoryphysician%22%2C%22directorynurse%22%5D%7D%2C%22customModel%22%3A%7B%22nurses%22%3Atrue%7D%7D颳去個別提供商的網址。從R網頁中用JavaScript抓取鏈接
我查看了頁面源和確定的感興趣的URL。例如,我想刮「http://www.childrenshospital.org/doctors/mirna-aeschlimann」形成如下節點
<a data-layer-event="searchClick" data-bind="attr: {href: model.Url}" href="http://www.childrenshospital.org/doctors/mirna-aeschlimann"><!--ko text: model.FirstName-->Mirna<!--/ko--><!--ko text: ' ' + model.LastName--> Aeschlimann<!--/ko--><!--ko if: model.Suffix-->, <!--ko text: model.Suffix-->MD<!--/ko--><!--/ko--></a>
我嘗試下面的代碼。但是,由於某些原因,它沒有返回上面的節點。
base_html <- "http://www.childrenshospital.org/directory?state=%7B%22showLandingContent%22%3Afalse%2C%22model%22%3A%7B%22search_specialist%22%3Afalse%2C%22search_type%22%3A%5B%22directoryphysician%22%2C%22directorynurse%22%5D%7D%2C%22customModel%22%3A%7B%22nurses%22%3Atrue%7D%7D"
doc <- htmlTreeParse(base_html, useInternal = TRUE)
任何幫助將不勝感激。請讓我知道是否應該提供更多信息。
查看'rvest'包[這裏](https://github.com/hadley/rvest)。 – Jeff
,你在調用'htmlTreeParse'後發現你沒有得到目標節點? – hrbrmstr