Created
July 12, 2018 21:29
-
-
Save fcschmidt/a992d1958d87c5d110b43cf693245f68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from selenium import webdriver | |
CHROMEDRIVER_PATH = "/app/.chromedriver/bin/chromedriver" # Heroku instance path | |
GOOGLE_CHROME_BIN_DEV = "/usr/bin/google-chrome" | |
CHROMEDRIVER_PATH_DEV = "/home/fcschmidt/.chromedriver/bin/chromedriver" | |
class GoogleChromeSelenium: | |
def __init__(self): | |
# chrome_bin = os.environ.get('GOOGLE_CHROME_BIN', "chromedriver") | |
chrome_bin = os.environ.get('GOOGLE_CHROME_BIN_DEV', ) | |
options = webdriver.ChromeOptions() | |
options.binary_location = chrome_bin | |
# options.add_argument("--disable-gpu") | |
# options.add_argument("--no-sandbox") | |
# options.add_argument('headless') | |
options.add_argument('window-size=1200x600') | |
self.driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH_DEV, chrome_options=options) | |
def crawler_url(self): | |
self.driver.get('https://google.com') | |
search = self.driver.find_element_by_xpath('//*[@id="lst-ib"]') | |
search.clear() | |
search.send_keys('facebook') | |
self.driver.find_element_by_xpath('//*[@id="tsf"]/div[2]/div[3]/center/input[1]').click() | |
self.driver.quit() | |
if __name__ == '__main__': | |
start = GoogleChromeSelenium() | |
start.crawler_url() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[default] | |
DEBUG = true | |
[development] | |
DEBUG = true | |
GOOGLE_CHROME_BIN = "/usr/bin/google-chrome" | |
CHROMEDRIVER_PATH = "/home/fcschmidt/.chromedriver/bin/chromedriver" | |
[production] | |
DEBUG = false | |
CHROMEDRIVER_PATH = "/app/.chromedriver/bin/chromedriver" | |
CHROME_BIN = "chromedriver" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment