wch / webshot

Take screenshots of web pages from R
http://wch.github.io/webshot/
228 stars 40 forks source link

webshot crashes when trying to screenshot Twitter user profiles; works otherwise #76

Open planetscape opened 5 years ago

planetscape commented 5 years ago

Code 1 [Fails]:

ws_URL <- c('https://twitter.com/Jack')
ws_filename <- c('Jack-viewport.png')
webshot(ws_URL, ws_filename, cliprect = "viewport", delay = 20.0, debug = TRUE)

Output 1:

[info] [phantom] Starting...
[info] [phantom] Running suite: 1 step
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 1/1: done in 31ms.
[info] [phantom] Step anonymous 2/2: done in 45ms.
[info] [phantom] Step _step 3/7: done in 64ms.
[debug] [phantom] opening url: https://twitter.com/Jack, HTTP GET
[debug] [phantom] Navigation requested: url=https://twitter.com/Jack, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://twitter.com/Jack"
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false

Error in webshot(ws_URL, ws_filename, cliprect = "viewport", delay = 20, : webshot.js returned failure value: -8
Traceback:

1. webshot(ws_URL, ws_filename, cliprect = "viewport", delay = 20, 
 .     debug = TRUE)
2. stop("webshot.js returned failure value: ", res)

Code 2 [Fails]:

ws_URL <- c('https://mobile.twitter.com/Jack')
ws_filename <- c('Jack-viewport.png')
webshot(ws_URL, ws_filename, cliprect = "viewport", delay = 20.0, debug = TRUE)

Output 2:

[info] [phantom] Starting...
[info] [phantom] Running suite: 1 step
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 1/1: done in 29ms.
[info] [phantom] Step anonymous 2/2: done in 43ms.
[info] [phantom] Step _step 3/7: done in 63ms.
[debug] [phantom] opening url: https://mobile.twitter.com/Jack, HTTP GET
[debug] [phantom] Navigation requested: url=https://mobile.twitter.com/Jack, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://mobile.twitter.com/Jack"
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.

Error in webshot(ws_URL, ws_filename, cliprect = "viewport", delay = 20, : webshot.js returned failure value: -8
Traceback:

1. webshot(ws_URL, ws_filename, cliprect = "viewport", delay = 20, 
 .     debug = TRUE)
2. stop("webshot.js returned failure value: ", res)

Code 3 [Succeeds]:

webshot("https://www.twitter.com/", "twitter-viewport.png", cliprect = "viewport", delay = 20.0, debug = TRUE)

Output 3:

[info] [phantom] Starting...
[info] [phantom] Running suite: 1 step
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 1/1: done in 33ms.
[info] [phantom] Step anonymous 2/2: done in 44ms.
[info] [phantom] Step _step 3/7: done in 63ms.
[debug] [phantom] opening url: https://www.twitter.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.twitter.com/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://twitter.com/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://twitter.com/"
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step _step 5/7 https://twitter.com/ (HTTP 200)
[info] [phantom] Step _step 5/7: done in 5151ms.
[debug] [phantom] url changed to "https://twitter.com/"
[info] [phantom] wait() finished waiting for 20000ms.
[info] [phantom] Step anonymous 6/7 https://twitter.com/ (HTTP 200)
[info] [phantom] Step anonymous 6/7: done in 25165ms.
[info] [phantom] Step anonymous 7/7 https://twitter.com/ (HTTP 200)
[debug] [phantom] Capturing page to /home/planetscape/Analysis of Tweets/twitter-viewport.png with clipRect {"top":0,"left":0,"width":992,"height":744}
[info] [phantom] Capture saved to /home/planetscape/Analysis of Tweets/twitter-viewport.png
[info] [phantom] Step anonymous 7/7: done in 25297ms.
[info] [phantom] Done 7 steps in 25297ms
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "about:blank"

​ sessionInfo():

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 18.04 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] webshot_0.5.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0        magrittr_1.5      usethis_1.4.0     devtools_2.0.1   
 [5] pkgload_1.0.2     uuid_0.1-2        R6_2.4.0          rlang_0.3.1      
 [9] tools_3.4.4       pkgbuild_1.0.2    sessioninfo_1.1.1 cli_1.0.1        
[13] withr_2.1.2       remotes_2.0.2     htmltools_0.3.6   assertthat_0.2.0 
[17] digest_0.6.18     rprojroot_1.3-2   crayon_1.3.4      processx_3.2.1   
[21] IRdisplay_0.7.0   callr_3.1.1       repr_0.19.2       fs_1.2.6         
[25] base64enc_0.1-3   ps_1.3.0          curl_3.3          testthat_2.0.1   
[29] IRkernel_0.8.15   glue_1.3.0        memoise_1.1.0     evaluate_0.13    
[33] pbdZMQ_0.3-3      compiler_3.4.4    backports_1.1.3   desc_1.2.0       
[37] prettyunits_1.0.2 jsonlite_1.6     

PhantomJS:

phantomjs/bionic,now 2.1.1+dfsg-2 amd64 [installed]
  minimalistic headless WebKit-based browser with JavaScript API