【发布时间】:2013-05-14 05:45:10
【问题描述】:
我正在尝试从this government website 的 API 自动下载一些数据。
网站说明:
All requests for this version should be made to the following URL:
http://api.finder.healthcare.gov/v2.0/
我可以找到很多关于如何发送 xml 请求的信息,但是没有一个例子是 R-specific.. 还有很多 R 代码展示了如何使用 XML、httr , 和RCurl 包,但我在 SO 或 r-help 邮件列表中找不到任何示例,说明如何实际发送 xml 请求。 ..还有更多用于解析响应的文档。
在the government website上,如果你点击PlansForIndividualOrFamily Samples的例子,它会显示需要发送的xml请求(代码如下)。
url <- "http://api.finder.healthcare.gov/v2.0/"
xml.request <-
"<?xml version='1.0' encoding='UTF-8'?>
<PrivateOptionsAPIRequest>
<PlansForIndividualOrFamilyRequest>
<Enrollees>
<Primary>
<DateOfBirth>1990-01-01</DateOfBirth>
<Gender>Male</Gender>
<TobaccoUser>Smoker</TobaccoUser>
</Primary>
</Enrollees>
<Location>
<ZipCode>69201</ZipCode>
<County>
<CountyName>CHERRY</CountyName>
<StateCode>NE</StateCode>
</County>
</Location>
<InsuranceEffectiveDate>2012-10-01</InsuranceEffectiveDate>
<IsFilterAnalysisRequiredIndicator>false</IsFilterAnalysisRequiredIndicator>
<PaginationInformation>
<PageNumber>1</PageNumber>
<PageSize>10</PageSize>
</PaginationInformation>
<SortOrder>
<SortField>OOP LIMIT - INDIVIDUAL - IN NETWORK</SortField>
<SortDirection>ASC</SortDirection>
</SortOrder>
<Filter/>
</PlansForIndividualOrFamilyRequest>
</PrivateOptionsAPIRequest>"
【问题讨论】:
-
你知道如何发送xml请求到api.finder.healthcare.gov/v2.0吗?