Python Selenium Tutorial #1 - Web Scraping, Bots & Testing

Tech With Tim · 1.6M views · 2020 · 11:41

Open on YouTube

Python, Ruby & scripting languagesTesting, debugging & developer toolsWeb developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as a quick starter for installing Selenium and getting a Chrome driver running, and askers often mention it as the tutorial they were following when they hit setup errors.

Recommended by 4 people across 4 different months, 2020 to 2022.

What it is

A beginner tutorial from Tech With Tim on using Python's Selenium module for web scraping, browser automation and testing. It covers installing Selenium, downloading the Chrome web driver, and opening a page and interacting with it through a driver.

What people said

Recommends some guy · 2020-08 · Stack Overflow · on “How to run a search engine script in Python?”

Why are you using text files? I don't get it. Either way, you could just use Python itself to do that. Use the selenium library for Python. There's a tutorial to installing this here [this video] . Once that's done, just use this code if you're using Google: from selenium import webdriver from selenium.webdriver.common.keys import Keys import time PATH = "C:\Program Files (x86)\chromedriver.exe" driver = webdriver.Chrome(PATH) driver.get(" [LINK] ") search = driver.find_element_by_css_selector(".gLFyf.gsfi") time.sleep(5) search.send_keys("Desired Input Text Goes Here") search.send_keys(Keys.RETURN) Don't worry if it takes a while to load. It usually does that. If you want to reduce the amount of

Recommends Jaime González Suárez · 2020-11 · Stack Overflow · on “How do you start a Selenium in Firefox or Chrome?”

Hello that is a very easy question to search in youtube there, there are a lot of videos to explain that properly then ( for example how to create chrome PATH) I think this video is a good point to start [this video] Thank you.

Recommends khalrab27 · 2020-12 · Stack Overflow · on “webbrowser open internet explorer error instead of default browser (python)”

If your default browser is Firefox or Chrome, you can use Selenium. To install Selenium: Open the command prompt/shell on your system and type: pip install selenium Firefox tutorial: [LINK] Chrome tutorial: [this video] I recommend taking a look at the Selenium for Python documentation if you're using either Firefox or Chrome. Selenium documentation: [LINK]

Recommends KailasMM · 2021-06 · Stack Overflow · on “Automator - a screenshot of a some part of a website. Is it possible?”

I think it is possible using selenium in python. Setup and installation of Selenium [this video] Selenium screenshots github repository [LINK]

Cites 7U4D · 2020-11 · Stack Overflow · on “FileNotFoundError: [Errno 2] No such file or directory: '/Users/fuadhafiz/Documents\\chromedriver.exec' error using Selenium on MAC OSX”

I am trying to learn how to use selenium and python as well i am trying to follow this video : [this video] This is the code I have : from selenium import webdriver PATH = "/Users/fuadhafiz/Documents\chromedriver.exec" driver = webdriver.Chrome(PATH) driver.get(" [LINK] ") But this is what keeps coming up on the terminal ( I am using VS Code and am on mac) /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 "/Users/fuadhafiz/Documents/Python Projects/Selenium Automation /Web Scraping (1)/web_scraping_attempt.py" fuadhafiz@Fuads-iMac Web Scraping (1) % /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 "/Users/fuadhafiz/Documents/Python Projects/Selenium Automation /Web Scrapi

Cites tomvanner · 2021-03 · Stack Overflow · on “I cant login instagram using requests”

TL;DR Add a user-agent [LINK] to your get request header on line 20: r = s.get(link, headers={'User-Agent': 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_7_3 rv:3.0; sl-SI) AppleWebKit/533.38.2 (KHTML, like Gecko) Version/5.0 Safari/533.38.2'}) Long answer If we look at the error message you posted, we can start to dissect what's gone wrong. Line 21 is attempting to find a csrf_token attribute on the instagram login page [LINK] . Diagnostics We can see from the error message that the list index is out of range, which in this case means that the list returned by re.findall ( docs [LINK] ) is empty. This means that either Your regex is wrong The html returned by your get request ( docs [LINK] )

Cites Nitro · 2022-06 · Stack Overflow · on “ModuleNotFoundError: No module named 'selenium'. How to fix it from Visual Studio Code?”

I don't know about virtual environments and what they do, but all I wanted was to start learning this tutorial on python: [this video] I did everything possible: pip install selenium pip3 install selenium installed and uninstalled it Added it in my environmental variables in the path. Like this: [LINK] Now what am I supposed to do? In Visual Studio Code I'm still getting this error no matter what I do and how many times I install, uninstall and add it to my environmental variables: [LINK]

Cites Chinmay Sahoo · 2022-10 · Stack Overflow · on “Google Chrome running in background without my knowledge”

Python is running because of Vscode and I don't know why Microsoft edge is running. And I used this tutorial to start ( [this video] )

Cites Rexsaa Gater · 2022-11 · Stack Overflow · on “How to stop browser closing in python selenium? without calling quit or close ()”

Description of the problem: The problem I'm stuck on is when I run a code, it first opens the chrome browser and opens the google.com website and then it closes it for no reason. This is my code: from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service opts = Options() opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36") PATH = "C:\Program Files (x86)\chromedriver.exe" driver_service = Service(executable_path=PATH) driver = webdriver.Chrome(service=driver_service,options=opts) driver.get(" [LINK] ") print("connected to: "