adding screenshot script

This commit is contained in:
2019-10-03 00:40:41 +01:00
parent 42e1808155
commit 9f28a9ddce
8 changed files with 100 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ from bs4 import BeautifulSoup
from selenium import webdriver
import emoji
from datetime import datetime
import re
url = 'http://www.trafficengland.com/traffic-alerts'
# prepare the option for the chrome driver
@@ -9,7 +10,7 @@ options = webdriver.ChromeOptions()
options.add_argument('headless')
# start the chrome driver
browser = webdriver.Chrome(chrome_options=options)
browser = webdriver.Chrome(options=options)
browser.get(url)
html = browser.page_source
@@ -28,16 +29,16 @@ list = []
for item in table:
list.append(item)
for i in range(0, 4):
print(list[i])
# for i in range(0, 4):
# print(list[i])
printBreak()
# printBreak()
totalItems = int(len(list) / 4)
# totalItems = int(len(list) / 4)
for i in range(0, 4):
print(list[i].string)
printBreak()
# for i in range(0, 4):
# print(list[i].string)
# printBreak()
newList = ([x.text for x in soup.find_all('td')])
@@ -47,8 +48,24 @@ print(emoji.emojize('Did someone say M62 :anguished:!? Let'
'\'s check the latest updates from Highways'
' England! :police_car::rotating_light:',
use_aliases=True))
print(f'As of {currentTime}, there is currently a {newList[2]} {newList[1]}'
print(f'As of {currentTime}, there is currently {newList[2]} {newList[1]}'
f' on the {newList[0]}')
# print(list[3].prettify())
print(str(list[3]))
desc = str(list[3])
descSplit = desc.split('<')
pattern = r"\>(.+?)\s+?\:\s+?(.+?)$"
for item in descSplit:
# print(item)
regex = re.findall(pattern, item)
# print(f'Type: {type(regex)}')
# print(f'Matches: {regex}')
try:
printBreak()
print(f'itemOne: {regex[0][0]}')
print(f'itemTwo: {regex[0][1]}')
except IndexError:
pass
# print(f'itemTwo: {regex[1]}')