r - rvest 包无法识别表单
问题描述
我想从以下网站抓取一些数据: http ://predstecajnenagodbe.fina.hr/pn-public-web/predmet/search 但是当我尝试使用 rvest 时:
library(rvest)
session <- html_session("http://predstecajnenagodbe.fina.hr/pn-public-web/predmet/search")
form <- html_form(session)
form
它找不到表单,即使它在那里(如您在页面上看到的那样)。
我也尝试过使用httr
包中的 POST 函数:
parameters <- list(since = "1.6.2018", until = "5.6.2018", `g-recaptcha-response` = "03AF6jDqXcBw1qmbrxWqadGqh9k8eHAzB9iPbYdnwzhEVSgCwO0Mi6DQDgckigpeMH1ikV70egOC0UppZsO7tO9hgdpEIaI04jTpG6JxGMR6wov27kEkLuVsEp1LhxZB4WFDRkDWdqcZeVN1YkiojUpje4k-swFG7tPyG2pJN86SdT290D9_0fyfrxlpfFNL2VUwE_c15vVthcBEdXIQ68V5qv7ZVooLiwrdTO2qLDLF1yUZWiu9IJoLuBWdFzJ_zdSP6fbuj5wTpfPdsYJ2n988Gcb3q2aYdn-2TVuWoQzqs1wbh7ya_Geo7_8gnDUL92l2nqTeV9CMY58fzppPPYDJcchdHFTTxadGwCGZyKC3WUSh81qiGZ5JhNDUpPnOO-MgSr5aPbA7tei7bbypHV9OOVjPGLLtqA9g")
httr::POST(
url,
body = parameters,
config = list(
add_headers(Referer = "http://predstecajnenagodbe.fina.hr"),
user_agent(get_header()),
accept_encoding = get_encoding(),
use_proxy("xxxx", port = 80,
username = "xxx", password = "xxxx"),
timeout(20L),
tcp_keepalive = FALSE
),
encode = "form",
verbose()
)
但它返回一些 JS 代码和消息:
请启用JavaScript查看页面内容。您的支持ID是:10544975822212666004
你能解释一下为什么rvest
不能识别表格以及为什么 POST 不能正常工作吗?
解决方案
推荐阅读
- android - 适用于 android 和 IOS 应用程序的 ssl-pinning 正确方法
- bash - 根据时间戳对文件中的行进行排序
- javascript - 事件 { "isTrusted": false } 使用 Expo 和 XMLHttpRequest
- deployment - 在暂存(完整)沙箱中测试发布工件
- php - 在本地 Mac OS 上使用 Supervisord 运行的 Laravel 应用程序的 Guzzle HTTP / Curl 错误 7
- powershell - 为什么管道不适用于转换后的 json 对象?
- sql - TDE - 删除列名中的架构名称和视图名称
- jupyter-notebook - 如何在数据框中添加预测值?
- math - 各种标准如何影响结果?
- python - 六个bind设置好了,bazel build protobuf_python no such package '@six//