-3

I'm trying to create a movie scraping script, but after running the last line of code from below I'm met with a

Error in rbind(deparse.level, ...) : 
  numbers of columns of arguments do not match 

And I'm not sure why.

  rottenrate <- function(movie){
              require(RJSONIO)
              link <- paste("http://www.omdbapi.com/?t=", movie, "&y=&plot=short&r=json&tomatoes=true", sep = "")
              jsonData <- fromJSON(link)
              return(jsonData)
            }
            vrottenrate <- Vectorize(rottenrate, "movie", SIMPLIFY = F)

val <- "http://www.fandango.com/valkilmer/filmography/p38142"
    val_movies <- readHTMLTable(val)
    val_movies <- as.data.frame(val_movies)
    val_movie_titles <- subset(val_movies, select = c(NULL.Title))
    val_movie_titles <- as.character(val_movie_titles$NULL.Title) 

val_completed <- do.call(rbind, lapply(vrottenrate(val_movie_titles), function(x) as.data.frame(t(x), stringsAsFactors = FALSE)))
halfer
  • 19,824
  • 17
  • 99
  • 186
Phillip Black
  • 105
  • 1
  • 2
  • 10
  • 6
    (a) There's an [omdbapi R package](https://github.com/hrbrmstr/omdbapi) and (b) you are in violation of Fandango's [Terms of Use](http://www.fandango.com/termsofuse) and anyone who helps you with code examples that touch Fandango is also in violation and subject to fines & judgements. – hrbrmstr Jul 07 '15 at 00:27
  • 1
    @hrbrmstr It is important that you point this out. But my feeling is that SO should think about a policy on how to handle such cases. I'm not a lawyer, but I've been wondering about this lately: if a person could get into legal trouble for answering a question posted on SO, one might wonder to which extent SO would be responsible in such a case too, since it published the question on the website and it may thus be argued that SO tacitly condoned the submission of valid replies. Why else would the question be published? – RHertel Jul 07 '15 at 04:06
  • 1
    @hrbrmstr: are you offering a qualified legal opinion for any reader in the whole world? As far as I recall I haven't signed that ToS, so I am not sure it applies to me. (I'm in the UK, if that affects your advice). – halfer Jul 07 '15 at 12:35
  • ToS apply whether you like them or not. It's up to you whether you want to support illegal activity or not and suffer any consequences as a result. – hrbrmstr Jul 07 '15 at 12:42
  • @hrbrmstr If you are not an attorney please stop giving legal advice. If you are an attorney you should know that giving legal advice over the internet is a very bad idea. – Ista Jul 07 '15 at 12:55
  • 1
    It's not legal "advice" it's warning people they are getting themselves into potential trouble for not reading and abiding by a site's _legal_ Terms of Service that most of you don't seem to think mean anything. They do. I've had 3 friends get cease & desist letters. They are very real. – hrbrmstr Jul 07 '15 at 14:27

1 Answers1

3

An easily solution is to use bind_rows from dplyr package or rbindlist from data.table package:

 kk<-lapply(vrottenrate(val_movie_titles), function(x) as.data.frame(t(x), stringsAsFactors = FALSE))

 library(dplyr)
 bind_rows(kk)

library(data.table)
rbindlist(kk,fill=TRUE)
Metrics
  • 15,172
  • 7
  • 54
  • 83
  • 3
    Any assistance to the OP for the Fandango portion of the OP question puts you in violation of the Fandango ToS per the comment to the OP q. – hrbrmstr Jul 07 '15 at 00:28
  • @hrbrmstr Maybe maybe not. At any rate citing your own previous comment can hardly count as support for your opinion. – Ista Jul 07 '15 at 13:11