import datetime import matplotlib.pyplot as plt from selenium import webdriver import urllib.request from selenium.webdriver.support.ui import Select n = input() w = input() time_ = input()
driverPath = 'chromedriver.exe' b = webdriver.Chrome(executable_path=driverPath) b.get('https://www.cwb.gov.tw/V8/C/W/OBS_Sat.html')
b.find_element_by_id('Tab' + n).click() b.find_element_by_xpath("//label[@for='area"+w+"']").click() sel = Select(b.find_element_by_id('selectday'))
format_time = datetime.datetime.strptime(time_,"%Y/%m/%d %H:%M") #print(format_time) #print(format_time.strftime("%Y/%m/%d %H:%M")) #print(time_) pic_src = [] for i inrange(6): sel.select_by_visible_text(format_time.strftime("%Y/%m/%d %H:%M")) format_time = format_time + datetime.timedelta(minutes =- 10) pic_src.append(b.find_element_by_xpath('//img[@alt="衛星雲圖"]').get_attribute('src')) print(pic_src) for idx,pic inenumerate(pic_src): plt.subplot(2,3,idx+1) s = urllib.request.urlopen(pic) p = plt.imread(s,'jpg') plt.imshow(p) plt.show() #2021/05/07 15:10