[英]R: Webscraping: XML content does not seem to be XML: Using HTMLParse
[英]Debugging htmlParse in R's XML library
這不是我第一次在XML庫中使用htmlParse
遇到問題,但在過去我只是放棄並使用正則表達式來解析我需要的東西。 我寧願通過解析XML / XHTML來做到這一點,因為我們都知道正則表達式不是解析器。
也就是說,我發現解析命令中的錯誤消息充其量只是無用的,我不知道如何繼續。 例如:
> htmlParse(getForm("http://www.takecarehealth.com/LocationSearchResults.aspx", location_query="Deer Park",location_distance=50))
Error in htmlParse(getForm("http://www.takecarehealth.com/LocationSearchResults.aspx", :
File
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="ctl00_Head1">
<title></title>
<script language="JavaScript" type="text/javascript">
var s_pageName = document.title;
var s_channel = "Take Care";
var s_campaign = "";
var s_eVar1 = ""
var s_eVar2 = ""
var s_eVar22 = ""
var s_eVar23 = ""
</script>
<meta name="keywords" content="take care clinic, walgreens clinic, walgreens take care clinic, take care health, urgent care clinic, walk in clinic" />
<meta name="description" content="Information about simple, quality healthcare for the whole family from Take Care Clinics at select Walgreens, including Take Care Clinic hours, providers, offers, insurance and quality of care." />
<link rel="shortcut icon" hre
我很高興看到那里的東西,但我在哪里深入了解“錯誤:文件”?
請注意,據我所知,格式良好的XHTML。 當我手動訪問鏈接時,我可以在其上運行xpaths並且Firebug不會抱怨。
如何調試htmlParse中的錯誤?
首先下載然后傳遞給XML包似乎工作
test<-getForm("http://www.takecarehealth.com/LocationSearchResults.aspx", location_query="Deer Park",location_distance=50)
htmlParse(test,asText=T)
或直接
htmlParse(getForm("http://www.takecarehealth.com/LocationSearchResults.aspx", location_query="Deer Park",location_distance=50),asText=T)
也好看
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.