A very short R-script to build a spam bot:
library(twitteR) ckey <- "1234mykey" csecret <- "1234mysecret" atoken <- "45678mytoken" asecret <- "56789othersecret" setup_twitter_oauth(ckey, csecret, atoken, asecret) LISTTopic <- twListToDF(searchTwitter('#BigData', n=10)) View(LISTTopic) LISTNames <- unique(LISTTopic$screenName) text.examples <- c("I am a bot, but I appreciate your work!", "Data is the new bacon!", "There are only 10 kinds of people: Those understanding binary code and others.", "Data is like people – interrogate it hard enough and it will tell you what you want to hear.", "Data that is loved tends to survive.") for(i in 1:length(LISTNames)){ message.text <- paste0("Hi @",LISTNames[i], " ", text.examples[sample(length(text.examples),1)]) print(nchar(message.text)) try({ updateStatus(message.text) }) -> temp if(class(temp)=="try-error"){ print('Error!') Sys.sleep(runif(1,50,100)) } else{ print(paste0('i= ',i,' (',LISTNames[i],') is DONE!')) Sys.sleep(runif(1,10,22)) } }
This little program uses the twitteR package to connect to the REST-API.
The bot takes 10 recent tweets on the topic of #BigData and sends a tweet with a direct mentioning. As text, the bot choses randomly one of five "data jokes".
That's all and the Sys.sleep function is not even necessary.
If you increase the number of tweets a lot and keep it running automatical, your account will probably be blocked in some hours. ;-)
Kommentare
Kommentar veröffentlichen