Skip to content

Instantly share code, notes, and snippets.

@willwade
Last active June 5, 2018 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willwade/74526677292ca459e4d340bed66e49ca to your computer and use it in GitHub Desktop.
Save willwade/74526677292ca459e4d340bed66e49ca to your computer and use it in GitHub Desktop.
restart-pm2
#!/usr/bin/env python
# virtualenv venv
# source venv/bin/activate
# pip install selenium
# cd venv/bin
# curl -O https://chromedriver.storage.googleapis.com/2.39/chromedriver_linux64.zip
# unzip chromedriver_linux64.zip
import re, urlparse
from selenium import webdriver
from time import sleep
import subprocess
link = 'https://aacinfo.email/posts'
class AACInfoScraper(object):
def __init__(self):
options = webdriver.ChromeOptions()
options.add_argument('headless')
self.driver = webdriver.Chrome('venv/bin/chromedriver', chrome_options=options)
self.driver.set_window_size(1120, 550)
def scrape(self):
sels = self.scrape_job_links()
self.driver.quit()
def scrape_job_links(self):
self.driver.get(link)
source = self.driver.page_source
# Products & Services
if 'Updates' in source:
print('Yes')
else:
print('No')
print subprocess.check_output(['pm2','restart','aacinfo'])
return True
if __name__ == '__main__':
scraper = AACInfoScraper()
scraper.scrape()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment