Web搜集大气数据-基于日期/时间的用户输入

时间:2018-08-26 17:34:31

标签: python web-scraping beautifulsoup

尝试根据日期/时间的用户输入打印大气数据。用于附加URL的日期输入。然后用户输入“时间”,它把BS4指向适当的行,然后从每一列存储数据。例如,如果weather_time变量在3:00-3:59之间,则输出将是表中突出显示的区域,并存储为唯一变量。

enter image description here

from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup

print('What is the date (format 2018-09-18)?')
weather_date = input()
print('What time are you looking for?')
weather_time = input()

#connect to url
weather_url = 'https://www.wunderground.com/history/daily/KTTD/date/' + weather_date
uClient = uReq(weather_url)
weather_html = uClient.read()
uClient.close()
weather_soup = soup(weather_html, "html.parser")
weather = weather_soup.findAll......
###magic####

temperature =
dew_point =
humidity =
pressure =
condition =

print('The weather on', + weather_date, 'at time', weather_time, 'was')
print('Temperature', + temperature)
print('Dew Point', + dew_point)
print('Humidity', + humidity)
print('Pressure', + pressure)
print('Condition', + condition)

0 个答案:

没有答案