Search code examples
rphantomjsrcrawler

Installing PhantomJS in R


I'm trying to install PhantomJS using the webshot package, SO I run the following on my machine:

webshot::install_phantomjs(force = TRUE)

At the end of the installation process I get the following:

phantomjs has been installed to /home/*******/bin

I go to that route and use the ls command to make sure phantomjs is there. When I type phantomjs on that directory I get the following:

Auto configuration failed
140184250763200:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: no se puede abrir el archivo del objeto compartido: No existe el archivo o el directorio
140184250763200:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
140184250763200:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
140184250763200:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf

Which is the same result I get when I type the following in R (webdriver::run_phantomjs())

  phantom.js started, but cannot connect to it on port 4830. stdout + stderr:
>  Auto configuration failed
>  140690466219968:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: no se puede abrir el archivo del objeto compartido: No existe el archivo o el directorio
>  140690466219968:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
>  140690466219968:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
>  140690466219968:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf

My objective is to use phantomjs in conjunction with the RCrawler package, but this is a necessary step. Any help is very much appreciated.

sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 22.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=es_ES.UTF-8       LC_NUMERIC=C               LC_TIME=es_ES.UTF-8       
 [4] LC_COLLATE=es_ES.UTF-8     LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=es_ES.UTF-8   
 [7] LC_PAPER=es_ES.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Lima
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] webshot_0.5.5    Rcrawler_0.1.9-1

loaded via a namespace (and not attached):
 [1] jsonlite_1.8.7    compiler_4.3.0    selectr_0.4-2     crayon_1.5.2     
 [5] promises_1.2.0.1  Rcpp_1.0.11       xml2_1.3.5        webshot2_0.1.0   
 [9] stringr_1.5.0     parallel_4.3.0    callr_3.7.3       later_1.3.1      
[13] png_0.1-8         fastmap_1.1.1     showimage_1.0.0   R6_2.5.1         
[17] curl_5.0.0        iterators_1.0.14  rlang_1.1.1       websocket_1.4.1  
[21] stringi_1.7.12    webdriver_1.0.6   doParallel_1.0.17 debugme_1.1.0    
[25] cli_3.6.1         withr_2.5.0       magrittr_2.0.3    ps_1.7.5         
[29] foreach_1.5.2     processx_3.8.2    rstudioapi_0.14   base64enc_0.1-3  
[33] lifecycle_1.0.3   chromote_0.1.1    glue_1.6.2        data.table_1.14.8
[37] codetools_0.2-18  httr_1.4.6        tools_4.3.0      

Solution

  • Try adding a wrapper script for phantomjs executable:

    • rename your current ~/bin/phantomjs to ~/bin/phantomjs.bin
    • create a new shell script and save it as ~/bin/phantomjs:
    #!/bin/sh
    export OPENSSL_CONF=/dev/null
    exec ~/bin/phantomjs.bin "$@"
    
    • make it executable: chmod +x ~/bin/phantomjs

    RCrawler should now execute the wrapper and phantomjs should pick up OPENSSL_CONF.