这不是我第一次在XML库中使用htmlParse时遇到问题,但在过去,我只是放弃了,而是使用regex来解析我需要的东西。我更愿意通过解析XML/XHTML来实现,因为我们都知道regexs不是解析器。
也就是说,我发现来自parse命令的错误消息充其量是没有帮助的,并且我不知道如何继续。例如:
> 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我很高兴它看到了一些东西,但是我在哪里可以深入到"Error: File“之后呢?
注意:据我所知,这是格式良好的XHTML。当我访问link manually时,我可以在上面运行xpath,Firebug没有抱怨。
如何像这样调试htmlParse中的错误?
发布于 2012-07-30 04:03:21
先下载,然后传递给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)看起来也很好
https://stackoverflow.com/questions/11712316
复制相似问题