How I Created 100 twitter bots and made them interact with each other with python.
Before starting this blog doesn’t have any code and please read everything to understand it fully. Happy reading.
It was long ago, somewhat in 2015, I took this project for self learning of creating bots on twitter and made them Interact. Here I am not gonna share any code or algorithm.
First let me list the technologies used for this purpose.
Now lets start with the tough part first which is Creating Twitter Bots.
For creating bot, I choose the selenium web driver. If you don’t know about selenium web driver, with this you can make your browser do particular events as instructed by the code. So I instructed the web driver to open twitter.com and fill up the signup form.
For username, name and password I wrote a script which scrape the name from a naming website and made the combinations and passwords. You can very easily write this script.
After filing this form you have the option to skip entering the phone number if your IP has not made more than one account in recent past. So with this method I was restricted in making only two from my network.
Now thats a problem, the next thing I tried is to make changes in User Agents which you can do in Selenium Web driver. Well this also didn’t work. I was stuck so I tried the different VPN which can work. But almost 99% time I am unable to make even one bot as the IP is already flagged by the Twitter.
Well talking about twitter, they are supper smart and flag and monitor every IP that has done any such identity of making fake accounts. Once the IP is flagged you cannot move forward without the phone number. Once option was using fake phone numbers to get the message online and then use it for creating account. This also didn’t work for me as the phone number websites were also flagged.
Now what, I have tried the VPN, changing user Agent and fake phone numbers, but nothing work.
For thinking about it for almost a week. An idea hit me, I came to know about AWS spot instances which are very cheap and you can make them cheaper with the bid they provide. Now I have a idea to make the accounts using these spot instances.
For this what all I have to setup and use is listed below.
- Spot instance with GUI since we have to use Selenium. So I used Windows server for this purpose.
- AWS apis to create spot instances from code and delete them after creating the account. In python I used BOTO EC2 for this purpose.
- A simple script to open the browser and fill the form and enter the details in a mysql database which is running somewhere else. It also checks if the username or any other entry didn’t repeat.
- For opening it in the startup I put the file python file in startup of windows.
- Every time a instance is launched browser opens up create two accounts and destroys the instance.
- I have configured an instance which does all this and made an AMI of the instance.
- Now I don’t have to configure every time. Just launch the instance with that AMI and it will do everything.
Again there is restriction that we must RDP to the windows instance to provide GUI so that selenium can run.
For this I wrote a shell script to login to the server using RDP just after launching my instance. Now the everything was setup and just have to run the code to get my accounts. I run the code and my 100 accounts were ready.
Now its really important what all information you save for every account for it to be accessible in future for our interactions with each other. Here is what I saved.
You may be wondering why location, I saved location to make sure twitter doesn’t block my account on basis on different locations I am accessing the accounts from.
Now there are two ways of making the accounts interact,
- Use the twitter apis and get the token from the twitter accounts and make them interact by sharing tweeting and retweeting posts.
- Use Selenium to do the same. Just keep in mind to use VPN and use the IP of location mapped to that particular account.
So this is how you can make your own farm of accounts on twitter and play with it.
Using AWS spot instances, cost of 100 accounts was around 20 INR, which is nothing if you get to learn this much.
Derived from the article below.
Before starting this blog doesn't have any code and please read everything to understand it fully. Happy reading. It…www.learnsteps.com
What to read more such Articles, Subscribe here