7-day Trial

Browser automation with Selenium

Picture of Eugene Stepnov

Try Gologin for free

Browser automation is simple to learn!

In the example below I will show you how to use Selenium for work with Gologin. Gologin technology allows you to use the Orbita browser, where you can use the unique browser snapshots through puppeteer. By setting up profiles on the gologin.com website you can emulate various devices, platforms, screen resolution, geolocation , timezone, availability of WebRTC , specify your proxies or proxies of the required country, etc.

At the same time cookies and a common browser fingerprint will be saved in the profile so that the site does not require re-authorization and it can be changed with another command if you need to emulate a new browser.

Selenium requires a chromedriver. It’s latest version for working with Gologin is located in the github.com/gologinapp/gologin repository in the selenium directory.

An example is given in Python (3.8)

The full parser code is presented below. I will analyze the main points separately.


import time
from sys import platform
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from gologin import Gologin

gl = Gologin({
 'token': 'yU0token',
 'profile_id': 'yU0Pr0f1leiD',
})

if platform == "linux" or platform == "linux2":
 chrome_driver_path = './chromedriver'
elif platform == "darwin":
 chrome_driver_path = './mac/chromedriver'
elif platform == "win32":
 chrome_driver_path = 'chromedriver.exe'

debugger_address = gl.start()
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", debugger_address)
driver = webdriver.Chrome(executable_path=chrome_driver_path, options=chrome_options)
driver.get("http://www.python.org")
assert "Python" in driver.title
driver.close()
time.sleep(3)
gl.stop()

										

The first step is to create an instance of the Gologin class. In its parameters, you need to specify the access token and the profile that we will run. The Orbita executable file is searched by default in the user’s directory (can be overridden by the executablePath parameter):


const GL = new Gologin({
 profile_id: 'yU0Pr0f1leiD',
 token: 'yU0token',
});
										

Then a command to launch remote browser is given and after receiving the link it is transmitted to Selenium:


debugger_address = gl.start()
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", debugger_address)
driver = webdriver.Chrome(executable_path=chrome_driver_path, options=chrome_options)
										

Next go to the python.org website and check that we got to the right place:


driver.get("http://www.python.org")
assert "Python" in driver.title

										

To complete the work close the driver and execute the profile stop

This way you can use Selenium browser automation for comfortable work with Gologin.

Also Read

  • Benchmarking The Rising Costs of Data Scraping

    There’s no doubt in stating that cloud computing enabled a wide range of new opportunities in the tech space, and this is true also for data scraping. Cheap virtual machines and storage enabled to scale the of activities to a new level, allowing companies to crawl a larger number of websites at a fraction of […]

  • High Level Principles to Scale Web Scraping Companies

    From Zero to Two Billion Prices Scraped Per Month Scaling web scraping companies can be difficult in modern climate, but it’s quite real. In this post I’ll write about what we did at Databoutique.com to scale from 0 to 2 Billion prices per month scraped, bootstrapped, and with a minimal team of developers. I’ll write […]

  • How To Сhoose The Right Web Scraping Proxy

    What are the key factors when choosing web scraping proxy? What is proxy diversity? Do proxies actually have reputation? Here’s a quick guide! What is IP Address and How It Works An Internet Protocol address (IP address) is a numerical label such as 192.0.2.1 that is connected to a network interface that uses the Internet […]