Created
July 16, 2018 22:22
-
-
Save miztiik/36d7ea949793f23dbd53121f8867097b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Install GeckoDriver | |
| cd /bin | |
| url=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | python -c "import sys, json; print(next(item['browser_download_url'] for item in json.load(sys.stdin)['assets'] if 'linux64' in item.get('browser_download_url', '')))") | |
| yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm | |
| yum -y install wget python-pip firefox | |
| wget $url | |
| tar -xvzf geckodriver-*-linux64.tar.gz | |
| rm -rf geckodriver-*-linux64.tar.gz | |
| chmod +x geckodriver | |
| cp geckodriver wires | |
| export PATH=$PATH:/bin/wires | |
| export PATH=$PATH:/bin/geckodriver | |
| # Install Selenium | |
| pip install selenium | |
| # npm install -g geckodriver | |
| # Create Screenshots | |
| python | |
| from selenium.webdriver import Firefox | |
| from selenium.webdriver.firefox.options import Options | |
| from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
| opts = Options() | |
| opts.set_headless() | |
| assert opts.headless # operating in headless mode | |
| browser = Firefox(options=opts, desired_capabilities=DesiredCapabilities.FIREFOX.copy()) | |
| browser.get('https://www.yahoo.com/') | |
| browser.get_screenshot_as_file('/tmp/m.png') | |
| browser.get('https://news.google.com/?hl=en-US&gl=US&ceid=US:en') | |
| browser.get_screenshot_as_file('/tmp/goog.png') | |
| browser.quit() | |
| exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment