Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions recipes/Python/Selenium_For_Web_Scraping/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Created on 2017-10-08

Author : Anish Kachinthaya <anishk23733@gmail.com>

Web scraping made simple with Seleniun
------------------------------------------------------------------

Selenium is a module for browser testing and web scraping.
In this code example, the Chromedriver opens google and enters "do a barrel roll" in the search box.

Modules required:
Selenium
* pip install selenium
Chromedriver (macOS):
* brew install chromedriver
Chromedriver (other):
* download driver from https://sites.google.com/a/chromium.org/chromedriver/downloads and place in PATH
19 changes: 19 additions & 0 deletions recipes/Python/Selenium_For_Web_Scraping/selenium_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Chrome()
driver.wait = WebDriverWait(driver, 5)
driver.get("https://www.google.com/")


search_box = driver.find_element_by_xpath('//*[@id="lst-ib"]')
search_box.send_keys("do a barrel roll", Keys.ENTER) # Or whatever you want to fill the text box with

time.sleep(5)

driver.quit()