v0.1 of send and receive scripts
This commit is contained in:
BIN
slack-bot/screenshot/cropped.png
Normal file
BIN
slack-bot/screenshot/cropped.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 118 KiB |
BIN
slack-bot/screenshot/screenshot.png
Normal file
BIN
slack-bot/screenshot/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 127 KiB |
6
slack-bot/screenshot/screenshot.py
Normal file
6
slack-bot/screenshot/screenshot.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from selenium import webdriver
|
||||
|
||||
driver = webdriver.Firefox()
|
||||
driver.get('https://www.python.org')
|
||||
driver.save_screenshot('screenshot.png')
|
||||
driver.quit()
|
||||
32
slack-bot/screenshot/screenshotFull.py
Normal file
32
slack-bot/screenshot/screenshotFull.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# https://stackoverflow.com/questions/41721734/take-screenshot-of-full-page-with-selenium-python-with-chromedriver/57338909#57338909
|
||||
|
||||
from selenium import webdriver
|
||||
from PIL import Image
|
||||
|
||||
URL = 'https://www.trafficdelays.co.uk/m62-traffic-delays/'
|
||||
|
||||
options = webdriver.ChromeOptions()
|
||||
options.headless = True
|
||||
|
||||
driver = webdriver.Chrome(options=options)
|
||||
driver.get(URL)
|
||||
|
||||
|
||||
def setWidth(var, adj=0):
|
||||
script = "return document.body.parentNode.scroll" + (var)
|
||||
return driver.execute_script(script) + adj
|
||||
|
||||
|
||||
driver.set_window_size(setWidth('Width'), setWidth('Height'))
|
||||
|
||||
|
||||
driver.find_element_by_tag_name('body').screenshot('web_screenshot.png')
|
||||
# driver.find_element_by_css_selector('#post-4706').screenshot('web_screenshot.png')
|
||||
|
||||
# print(driver.find_element_by_css_selector('#post-4706').text)
|
||||
|
||||
im = Image.open('web_screenshot.png')
|
||||
width, height = im.size
|
||||
region = im.crop((0, 0, width, 880))
|
||||
region.save('cropped.png')
|
||||
driver.quit()
|
||||
BIN
slack-bot/screenshot/web_screenshot.png
Normal file
BIN
slack-bot/screenshot/web_screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 833 KiB |
Reference in New Issue
Block a user