如何在R中使用POST从web请求数据
How to use POST to request data from web in R
我正在学习R从一些网站获取数据。在这里,我试图使用R请求波士顿马拉松比赛结果从这个网站。
下面是我的代码:library(httr)
login <- list(RaceYearLowID = "2016", LastName = "Desisa",
FirstName = "Lelisa", submit_button = "Search")
url <- "http://registration.baa.org/cfm_Archive/iframe_ArchiveSearch.cfm?mode=results&RequestTimeout=600&snap=47418326&"
res <- POST(url, body = login, verbose())
我得到的结果是:
-> POST /cfm_Archive/iframe_ArchiveSearch.cfm?mode=results&RequestTimeout=600&snap=47418326&
HTTP/1.1
-> Host: registration.baa.org
-> User-Agent: libcurl/7.50.3 r-curl/2.1 httr/1.2.1
-> Accept-Encoding: gzip, deflate
-> Accept: application/json, text/xml, application/xml, */*
-> Content-Length: 467
-> Expect: 100-continue
-> Content-Type: multipart/form-data; boundary=------------------------47d84f94847f4213
-> <- HTTP/1.1 100 Continue
>> --------------------------47d84f94847f4213
>> Content-Disposition: form-data; name="RaceYearLowID"
>>
>> 2016
>> --------------------------47d84f94847f4213
>> Content-Disposition: form-data; name="LastName"
>>
>> Desisa
>> --------------------------47d84f94847f4213
>> Content-Disposition: form-data; name="FirstName"
>>
>> Lelisa
>> --------------------------47d84f94847f4213
>> Content-Disposition: form-data; name="submit_button"
>>
>> Search
>> --------------------------47d84f94847f4213--
<- HTTP/1.1 200 OK <- Date: Tue, 18 Oct 2016 17:47:31 GMT <- Server:
Microsoft-IIS/6.0 <- X-Powered-By: ASP.NET <- Set-Cookie:
CFID=7150121;expires=Thu, 11-Oct-2046 17:47:31 GMT;path=/ <-
Set-Cookie: CFTOKEN=95945596;expires=Thu, 11-Oct-2046 17:47:31
GMT;path=/ <- Set-Cookie: BAAARCHIVE_ISON=Testing;path=/ <-
Set-Cookie: CFID=7150121;path=/ <- Set-Cookie: CFTOKEN=95945596;path=/
<- Set-Cookie: BIGipServerBAA_registrationpool=304677130.20480.0000;
path=/ <- Transfer-Encoding: chunked <- Content-Type: text/html;
charset=UTF-8 <- Via: 1.1 dc1wsa01.na.coherentinc.com:80
(Cisco-WSA/9.1.1-074) <- Connection: close <-
>
我查看了BAA网站的源代码,它是基于JavaScript函数的。任何建议吗?谢谢!
谢谢大家。我知道怎么得到结果了。代码如下:
login <- list(RaceYearLowID = "2014", LastName = "Smithson")url<——"http://registration.baa.org/cfm_Archive/iframe_ArchiveSearch.cfm?mode=results& RequestTimeout = 600,提前= 47418326,"
res <- POST(url, body = login, verbose(),encode = "form")
doc2<-htmlTreeParse(res,encoding = "utf-8",asText = TRUE)
doc2被解析为html样式。下一步是如何从这个html文件中获取数据。
相关文章:
- Python Flask Web服务器未接收到JSON ajax POST请求,服务器返回HTTP 200 OPTION
- 如何使用 AJAX 发送 POST 数据?以及如何在Web API中获取POST数据
- 通过电子邮件将 AJAX POST 发送到 Web API
- How to POST javascript Blob to JAX-WS Web service
- 多个链式 jQuery AJAX POST Web 服务调用
- jQuery ajax post current date time ASP.NET web API
- 如何使用 Web 表单(不是 MVC 或 asmx 页面)从 ajax Http POST 获取 c# 服务器端的复选框
- AngularJS $http.post ASP.NET 具有简单类型参数的 Web API 控制器
- AngularJS允许POST或PUT跨域的Web服务
- 如何使用Angular将JSON和文件POST到web服务
- Python POST JSON-是必需的web框架
- AngularJS$http://.NET Web API-获取400(错误请求)或NULL POST操作方法参数
- 如何在POST方法之后将更改应用于web
- Angular 2 http post null Web Api Core
- 为什么我没有使用$.post()从我的Sinatra web服务获得响应?
- Web API字符串参数和POST值
- 访问javascript端POST请求返回的IEnumerable (web API)
- 如何在R中使用POST从web请求数据
- 使用POST调用RESTFUL web服务
- 跨域$.ajax POST到REST Web服务