v0.1 of send and receive scripts

This commit is contained in:
2019-10-06 23:04:08 +01:00
parent 43984913b8
commit a843d35c7b
15 changed files with 279 additions and 28 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

View 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()

View 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()

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 KiB