英文:
Getting 'Undefined error in httr call' when using remDr$navigate with R Selenium - how to fix it?
问题
remDr$navigate (url) 错误:httr 调用中未定义的错误。httr 输出:length(url) == 1 不是 TRUE
这是发生在以下网址上的:
url <- "https://eprel.ec.europa.eu/screen/product/airconditioners"
远程驱动程序没有配置错误。可能的原因是什么,如何解决?也许这个网站无法爬取?
我尝试检查:
- URL 的规范(是正确的)
- 使用 get() 和 navigateTo() 函数。
我的系统是64位的,R也是64位的,但是Chrome和Firefox的webdriver只有32位的可用版本。这可能是问题吗?
ChatGPT说这可能与RSelenium的设置或与特定网站的兼容性有关。也许对于这个网站,应该使用另一个爬取工具或包?
英文:
remDr$navigate (url) error: Undefined error in httr call. httr output: length(url) == 1 is not TRUE
This happens for URL
url <- "https://eprel.ec.europa.eu/screen/product/airconditioners"
Remote driver is configured without errors. What could be the cause and how to solve it? Is it perhaps that this website is not scrape-able?
I tried checking:
- the specification of URL (it's correct)
- using get() and navigateTo functions.
My system is 64-bit, and so is R, but the only available versions for webdriver for Chrome and Firefox are 32-bit. Could that be the problem?
The ChatGPT says it could be related to the RSelenium setup or compatibility with the specific website.
Could it be that for this website, another scraping tool/package should be used?
答案1
得分: 0
试试这个替代方案:
library(tidyverse)
library(httr2)
"https://eprel.ec.europa.eu/api/products/airconditioners?_page=1&_limit=25&indoorSoundPowerCoolingMin=1&indoorSoundPowerCoolingMax=99&outdoorSoundPowerCoolingMin=0&outdoorSoundPowerCoolingMax=99&indoorSoundPowerHeatingMin=1&indoorSoundPowerHeatingMax=99&outdoorSoundPowerHeatingMin=0&outdoorSoundPowerHeatingMax=99&coolingDesignLoadMin=0.1&coolingDesignLoadMax=99.9&heatingDesignLoadMin=0.1&heatingDesignLoadMax=99.9&sort0=onMarketStartDateTS&order0=DESC&sort1=energyClass&order1=DESC" %>%
request() %>%
req_perform() %>%
resp_body_json(simplifyVector = TRUE, check_type = FALSE) %>%
pluck("hits")
英文:
Try this instead:
library(tidyverse)
library(httr2)
"https://eprel.ec.europa.eu/api/products/airconditioners?_page=1&_limit=25&indoorSoundPowerCoolingMin=1&indoorSoundPowerCoolingMax=99&outdoorSoundPowerCoolingMin=0&outdoorSoundPowerCoolingMax=99&indoorSoundPowerHeatingMin=1&indoorSoundPowerHeatingMax=99&outdoorSoundPowerHeatingMin=0&outdoorSoundPowerHeatingMax=99&coolingDesignLoadMin=0.1&coolingDesignLoadMax=99.9&heatingDesignLoadMin=0.1&heatingDesignLoadMax=99.9&sort0=onMarketStartDateTS&order0=DESC&sort1=energyClass&order1=DESC" %>%
request() %>%
req_perform() %>%
resp_body_json(simplifyVector = TRUE, check_type = FALSE) %>%
pluck("hits")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论