1

这不是我第一次在使用htmlParseXML 库时遇到问题,但过去我刚刚放弃并使用来解析我需要的内容。我宁愿通过解析 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 的错误?

4

1 回答 1

3

先下载然后传递到 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)

看起来也不错

于 2012-07-29T20:03:21.407 回答