Python twitter bot in selenium

irishbeastman

Newbie
Joined
Feb 2, 2020
Messages
2
Reaction score
0
I have a fully automated python twitter bot using the selenium package. After one day twitter has already asked for additional verification (not surprising since I haven't tried to spoof twitter yet). I just wanted to test how easily it would be picked up.

So, I've been reading that the following can help:
- changing IP address
- changing javascript variables such as user agents to be in line with a human browsing.

However if I do that, then the following problem exits. When I first run the python script and load the twitter homepage there is no human mouse movement. I simply get the element associated with login form for username/password and enter my details.

Clearly there is no mouse movement and so surely it will easily be detected as a bot. Can someone point me in the direction how I can spoof human mouse movements please?

Can someone also explain how mouse movements are detected in javascript on their server? I have a basic understanding of how javascript work.

Thanks in advance.
 
Have you protected selenium? As it is VERY easy to detect the base selenium? Selenium by default adds variables saying "I AM SELENIUM". Removing those is straight forward, but then there are other tell tale marks you are using selenium, again can be removed. But then things such as no mouse movement, or not-realistic mouse movement. The page being intereacted with when the browser is minimised / not visible / not active etc etc getting more and more complex
 
By faking mouse movements you're delving into the überblackhat domain, where few have gone before.
 
Thanks for your replies. This is my first post on the forum so excuse me if I ask "basic" questions. I'm mainly experience in python but started learning javascript to help me with this project.

1. How would I get a "protected selenium"? I've read that for example I would need to change the user agent information that they receive from my end. Do you basically mean changing javascript variables? Or something more?

2. I have been reading that in selenium you can implement mouse movements. But all it seems to do is for example get an element by id and hover over it. But you are still jumping from (0,0) --> (10,5) instantly? So you would be easily identified as a bot because you are jumping so much. Is my understanding correct?
How would I inject human randomness into this. It seems you can't do it via javascript, so can you guys point me in the right direction? Perhaps some articles.

Thanks in advance.
 
By faking mouse movements you're delving into the überblackhat domain, where few have gone before.
Not sure about that. Is quite easy to get libraries that can actually move the mouse. Granted you cannot use the machine at the same time, but you shouldn't really so the browser can be active and displayed.

Then just use spline / bezier curves to go from point to point. To get really blackhat, record mouse movements on your websites and then use those in selenium. This will be much easier than trying to do it in JS where you need to trigger mouseenter, mouseover, mouse exit all elements below.

If you want to level up, use something like XVFB to get a virtual frame buffer you can route the output to and apply a mouse to and not effect the base machine.
 
Trying to automate twitter with selenium an got the same problem. i added phone number and they're stop asking for bot but my account just suspended after 2 days. Any solution for it now ?
 
Trying to automate twitter with selenium an got the same problem. i added phone number and they're stop asking for bot but my account just suspended after 2 days. Any solution for it now ?
Have you gone the basics to stop selenium being detected?

$cdc_ variable

remove the document / navigator.webdriver property? I believe some flags on starting selenium can do this, or you can write a quick webextension and load it in to do it on pre page load
 
Have you gone the basics to stop selenium being detected?

$cdc_ variable

remove the document / navigator.webdriver property? I believe some flags on starting selenium can do this, or you can write a quick webextension and load it in to do it on pre page load
Not yet but i'm trying to learn now. Newbie and it's hard :(
Can u give me any source or document about that ?
Thanks
 
google browser fingerprinting {detection | avoidance}
how to protect selenium from detection
etc etc

then read up :)
 
google browser fingerprinting {detection | avoidance}
how to protect selenium from detection
etc etc

then read up :)
i followed tutorial on this thread
https://stackoverflow.com/questions/33225947/can-a-website-detect-when-you-are-using-selenium-with-chromedriver/41220267 Tried to replace the cdc signature, navigator.webdriver, use a extension which can fake fingerprint but i just got detected after 1 hour :D
 
i followed tutorial on this thread
https://stackoverflow.com/questions...are-using-selenium-with-chromedriver/41220267 Tried to replace the cdc signature, navigator.webdriver, use a extension which can fake fingerprint but i just got detected after 1 hour :D

In the past, I've had good result controlling the ACTUAL mouse, rather than use selenium element click functions. Not for twitter, but on other sites. If you use selenium to click an element, it raises the mouse_click event, but the site can detect you didn't trigger any other mouse events (move, enter, exit etc). Additionally just moving the mouse in a straightline was detected, so bezier curves can work well (or some other random non-linear movement.

But there could be other properties they are detecting. I haven't kept uptodate with browser fingerprint in recent times, so no doubt they are getting better at detecting.
 
Back
Top