chevron_left chevron_right
Login Register invert_colors photo_library


Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Lunar Building web bots with selenium filter_list
Author
Message
Building web bots with selenium #1
Selenium is a great framework that integrates with chrome (on linux) and firefox. It gives users easy access to DOM traversal tools like finding elements via css selectors, xpath, id, and a myriad of other methods.

The module also has the capacity to send special keys like enter and is able to click on elements.

Below is a quick demonstration of a bot that logs into facebook.

Code:
from selenium import webdriver,keys
from sys import argv

driver=webdriver.Firefox()                    # initialize the driver
driver.get('https://www.facebook.com/')        # go to the facebook login page

# assign the 'username' variable to the DOM element with id 'email'
username=driver.get_element_by_id('email')
# assign the 'password' variable to the DOM element with id 'pass'
password=driver.get_element_by_id('pass')

# enter credentials (supplied by script arguments)
username.send_keys(argv[1])
password.send_keys(argv[2])

# find and click the login button
driver.get_element_by_id('u_0_w').click()

Originally, I was going to make it a spambot, but that's a lot of code for a simple demonstration, and you guys can figure it out for yourselves Tongue

To install, simply run (on linux, add sudo obviously):
Code:
// python 2
pip install selenium

// python 3
pip3 install selenium

All this said, Selenium is pretty cool, but super heavyweight and shouldn't be used for retrieving html data. Use the requests module for that.

[+] 2 users Like Valkyrie's post
Reply

RE: Building web bots with selenium #2
Another thing to add to my list to screw around with once I get my Arch install up and running on my desktop

There is so much stuff you post I want to try out, my list is getting overwhelming Tongue
[Image: pBD38Xq.png]
Email: insidious@protonmail.ch

[+] 1 user Likes insidious's post
Reply

RE: Building web bots with selenium #3
I made My Facebook account creator bot using mechanize but may switch

Reply

RE: Building web bots with selenium #4
I used to work with PantomJS which actually caused us a lot of trouble. Does anybody know what are the main differences between the two of them?

Reply

RE: Building web bots with selenium #5
(08-21-2016, 12:49 PM)NaB3nzo Wrote: I used to work with PantomJS which actually caused us a lot of trouble. Does anybody know what are the main differences between the two of them?
Here you go, http://www.assertselenium.com/headless-t...framework/
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

[+] 1 user Likes Ex094's post
Reply

RE: Building web bots with selenium #6
(08-21-2016, 01:32 PM)Ex094 Wrote:
(08-21-2016, 12:49 PM)NaB3nzo Wrote: I used to work with PantomJS which actually caused us a lot of trouble. Does anybody know what are the main differences between the two of them?
Here you go, http://www.assertselenium.com/headless-t...framework/
Oh thanks!

Reply

RE: Building web bots with selenium #7
You can actually use PhantomJs as a WebDriver for selenium if you want to use a headless browser. It loads much faster than using chromedriver or another driver that has to actually open the web page. The only issue I've ran across while using the PhantomJs webdriver is that some websites just cant be accessed for whatever reason. For example, I tried to access adidas.com for a auto checkout bot I was writing, the only problem is that phantomjs stalled when trying to open the page. It didn't stall when trying to access other pages like google.com or youtube or whatever, so I'm wondering if this one site is just an anomaly.

Reply

RE: Building web bots with selenium #8
Selenium is easy to use, but is pretty slow.
They also have a browser plugin that you can record yourself using a page with (and it'll do the same thing).

I made an Instagram signup bot a while ago, I figured out that you can DOS a private Instagram account by making tons of bots try to follow the account, never finished the bot though.
(This post was last modified: 12-18-2016, 10:27 PM by Blink.)


(11-02-2018, 02:51 AM)Skullmeat Wrote: Ok, there no real practical reason for doing this, but that's never stopped me.

Reply

RE: Building web bots with selenium #9
I am loving python and selenium for some of my first python coding!

Reply






Users browsing this thread: 1 Guest(s)