url2neomatrix_ex2.py
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
#code(Python){{
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))
#with open("ex2.png","wb") as aaa:
# aaa.write(im_crop)
im_crop.save("ex2.png")
print('end save ex2.png')
subprocess.run(['/home/pi/python/pi_i2c_nano_neomatrix_ex...
}}
終了行:
#code(Python){{
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))
#with open("ex2.png","wb") as aaa:
# aaa.write(im_crop)
im_crop.save("ex2.png")
print('end save ex2.png')
subprocess.run(['/home/pi/python/pi_i2c_nano_neomatrix_ex...
}}
ページ名: