Prechádzať zdrojové kódy

Add mac driver

Signed-off-by: Michael Tang <michael.h.tang@gmail.com>
Michael Tang 4 rokov pred
rodič
commit
7fd4a29a5f
7 zmenil súbory, kde vykonal 2250 pridanie a 1 odobranie
  1. 2126 0
      LA_9_3_chatlog.rtf
  2. 21 0
      bcit.py
  3. BIN
      chromedriver_mac
  4. 2 1
      session.py
  5. 0 0
      session2.py
  6. 40 0
      smartfind.py
  7. 61 0
      vpl.py

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2126 - 0
LA_9_3_chatlog.rtf


+ 21 - 0
bcit.py

@@ -0,0 +1,21 @@
+import time
+import re
+from selenium import webdriver
+from bs4 import BeautifulSoup
+
+DRIVER_PATH = "/Users/michaeltang/.wdm/drivers/chromedriver/88.0.4324.96/mac64/chromedriver"
+URL = "https://www.bcit.ca/"
+
+# This loads webdriver from the local machine if it exists.
+browser =  webdriver.Chrome(DRIVER_PATH)
+browser.get(URL)
+
+# Give the browser time to load all content.
+time.sleep(4)
+
+search = browser.find_element_by_css_selector("#site-header-search")
+search.send_keys("Analytics")
+
+# Find the search button - this is only enabled when a search query is entered
+button = browser.find_element_by_css_selector(".site-header__search-btn")
+button.click() # Click the button

BIN
chromedriver_mac


+ 2 - 1
session.py

@@ -11,7 +11,8 @@ global URL
 global whoHereFor
 
 # path to chromedriver
-DRIVER_PATH = "/home/michtang/selenium/chromedriver"
+# DRIVER_PATH = "/home/michtang/selenium/chromedriver"
+DRIVER_PATH = "/Users/michaeltang/Documents/selenium/chromedriver_mac" 
 driver = webdriver.Chrome(DRIVER_PATH)
 
 def checkIn():

+ 0 - 0
session2.py


+ 40 - 0
smartfind.py

@@ -0,0 +1,40 @@
+import time
+from selenium import webdriver
+from bs4 import BeautifulSoup
+
+DRIVER_PATH = "/Users/michaeltang/.wdm/drivers/chromedriver/88.0.4324.96/mac64/chromedriver"
+URL = "https://epsb.eschoolsolutions.com/substituteAvailableJobAction.do"
+
+
+
+# This loads webdriver from the local machine if it exists.
+browser =  webdriver.Chrome(DRIVER_PATH)
+browser.get(URL)
+
+# Give the browser time to load all content.
+userId = browser.find_element_by_css_selector("#userId")
+userId.send_keys("9656618")
+userPin = browser.find_element_by_css_selector("#userPin")
+userPin.send_keys("nCytosub7410")
+loginButton = browser.find_element_by_css_selector("#submitBtn")
+loginButton.click()
+
+logged_in = False
+
+while not logged_in:
+    try:
+        availableJobsSelector = browser.find_element_by_css_selector("#sidious\.menu\.title\.AvailableJobs")
+        availableJobsSelector.click()
+    except:
+        print("Not logged in yet! Waiting 5 seconds...")
+        time.sleep(1)
+    else:
+        print("Successfully logged in!")
+        logged_in = True
+#availableJobsSelector.click()
+time.sleep(2)
+endDatePicker = browser.find_element_by_css_selector("#endDate")
+endDatePicker.clear()
+endDatePicker.send_keys("06/30/2021")
+search = browser.find_element_by_css_selector(".submitButton")
+search.click()

+ 61 - 0
vpl.py

@@ -0,0 +1,61 @@
+import time
+import re
+from selenium import webdriver
+from bs4 import BeautifulSoup
+
+DRIVER_PATH = "/Users/michaeltang/.wdm/drivers/chromedriver/88.0.4324.96/mac64/chromedriver"
+URL = "https://vpl.bibliocommons.com/events/search/index"
+
+# This loads webdriver from the local machine if it exists.
+browser =  webdriver.Chrome(DRIVER_PATH)
+browser.get(URL)
+
+# Give the browser time to load all content.
+time.sleep(4)
+
+button = browser.find_element_by_css_selector(".btn-lg")
+for i in range(0,20):
+    button.click()
+    '''
+    If you see the following error increase the sleep time:
+    ElementClickInterceptedError: element click intercepted:
+    '''
+    print("Count: ", str(i))
+    time.sleep(4)
+print("done loop")
+content = browser.find_elements_by_css_selector(".event-row")
+for e in content:
+    textContent = e.get_attribute('innerHTML')
+    # Beautiful soup allows us to remove HTML tags from our content if it exists
+    soup = BeautifulSoup(textContent, features="lxml")
+    rawString = soup.get_text().strip()
+
+    # Remove hidden characters for tabs and new lines.
+    rawString = re.sub(r"[\n\t]*", "", rawString)
+
+    # Replace two or more consecutive empty spaces with '*'
+    rawString = re.sub('[ ]{2,}', '*', rawString)
+
+    #Fine tune the results os they can be parsed.
+    rawString = rawString.replace("Location", "Location*")
+    rawString = rawString.replace("Registration closed", "Registration closed*")
+    rawString = rawString.replace("Registration required", "Registration required*")
+    rawString = rawString.replace("In Progress", "*In Progress*")
+    rawString = rawString.replace("*/*", "/")
+    rawString = rawString.replace("Full*", "*Full*")
+
+    #print(rawString)
+    eventArray = rawString.split('*')
+
+    EVENT_NAME = 0
+    EVENT_DATE = 1
+    EVENT_TIME = 2
+    eventName = eventArray[EVENT_NAME]
+    eventDate = eventArray[EVENT_DATE].strip() # remove leading and trailing spaces
+    eventTime = eventArray[EVENT_TIME].strip() # remove leading and trailing spaces
+    location = eventArray[len(eventArray)-1]
+    print("Name:      " + eventName)
+    print("Date:      " + eventDate)
+    print("Time:      " + eventTime)
+    print("Location:  " + location)
+    print("***")