Skip to content

Instantly share code, notes, and snippets.

import requests
from bs4 import BeautifulSoup
leads = []
rates = []
for i in range(3):
url = "https://www.greatschools.org/virginia/manassas/prince-william-county-public-schools/schools/?page={}".format(i)
r = requests.get(url, headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36'})
soup = BeautifulSoup(r.text, 'lxml')
@KameronKales
KameronKales / great.py
Created March 2, 2018 23:38
Here is the fixed file.
### The only change I made was to add {}".format(i) so that python new to substitute each i into the string!
import requests
from bs4 import BeautifulSoup
for i in range(93):
url = "https://www.greatschools.org/virginia/manassas/prince-william-county-public-schools/schools/?page={}".format(i)
r = requests.get(url, headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36'})
soup = BeautifulSoup(r.text, 'lxml')
@KameronKales
KameronKales / HTTPResponse.js
Created November 13, 2017 22:16
This is the code to check a valid HTTP response
function HTTPResponse( uri )
{
var response_code ;
try {
response_code = UrlFetchApp .fetch( uri ) .getResponseCode() .toString() ;
}
catch( error ) {
response_code = error .toString() .match( / returned code (\d\d\d)\./ )[1] ;
}
finally {
@KameronKales
KameronKales / token.py
Created October 4, 2017 21:53
Sample tokenize sentence from file
import spacy
import codecs
nlp = spacy.load('en')
## Include the file name below ##
multiSentence = codecs.open(
"kam_li.txt", 'r', encoding='ascii', errors='ignore').read()
doc = nlp(multiSentence.decode('utf-8'))
@KameronKales
KameronKales / alexa.py
Created January 20, 2017 21:24
basic layout to launch the alexa skill, ask to book a conference room & have it done for you in the background!
import logging
from flask import Flask, render_template
from flask_ask import Ask, statement, question, session
app = Flask(__name__)
ask = Ask(app, "/")
logging.getLogger("flask_ask").setLevel(logging.DEBUG)
@KameronKales
KameronKales / book_conference.py
Created January 20, 2017 21:16
the last bit of our selenium browser code
booking_button = browser.find_element_by_xpath("//a[contains(.,'Make a booking ($0.00) ')]").click()
save_button = browser.find_element_by_xpath("//*[@id='modal_booking']/form")
t.sleep(5)
save_button.submit()
print save_button.submit()
@KameronKales
KameronKales / send_time.py
Created January 20, 2017 20:46
gist to send time to form
end_time.send_keys(end_time_of_room)
begin_time.send_keys(begin_time_of_room)
t.sleep(5)
@KameronKales
KameronKales / final_formatting.py
Created January 20, 2017 20:44
final formatting of datetime needed for alexa skill
from datetime import datetime as dt
begin_time_of_room = str(hq_date) + ' ' + '-' + ' ' + str(current_hour) + ":" + str(time) + ' ' + str(period)
end_time_of_room = str(hq_date) + ' ' + '-' + ' ' + str(end_hour) + ":" + str(time) + ' ' + str(period)
@KameronKales
KameronKales / time.py
Created January 20, 2017 20:24
last portion of time formatting needed
from datetime import datetime as dt
hour = dt.now().hour
for i in str(hour):
if hour < 12 and time != '00':
current_hour = hour
end_hour = current_hour + 1
period = "AM"
elif hour < 12 and time == '00':
@KameronKales
KameronKales / time_formatted.py
Created January 20, 2017 20:21
gist to determine next available conference room
from datetime import datetime as dt
minute = dt.now().minute
if minute <= 60:
if minute <=15:
time = 15
elif minute <=30:
time = 30
elif minute <=45: