1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
-
|
!
| from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
from PIL import Image
import requests
import os
import subprocess
import sys
driver = webdriver.Chrome("/home/pi/chromedriver")
print( 'number of arguments:', len(sys.argv), 'arguments.')
arglist = sys.argv
print( 'Argument List:', sys.argv)
url=arglist[1]
print( 'url=', url)
driver.get(url)
driver.save_screenshot("ex1.png")
driver.close()
img = Image.open("ex1.png")
img_w, img_h = img.size
print('img_h:',img_h,',img_w:',img_w)
img_wc=img_w/2
img_hc=img_h/2
lx=img_wc-155
rx=img_wc+155
uy=img_hc-270
dy=img_hc+270
im_crop = img.crop((lx,uy,rx,dy))
im_crop.save("ex2.png")
print('end save ex2.png')
subprocess.run(['/home/pi/python/pi_i2c_nano_neomatrix_ex7.py','ex2.png'])
|