def __init__(self, uri): self.seatemps = [] html = util.html_get(uri) soup = BeautifulSoup(html, 'html.parser') templine = str(soup.find(id='temp1')) m = re.search("<h3>([0-9.]+)", templine) self.temp = m.group(1)
def __init__(self, uri): self.rains = [] html = util.html_get(uri) forecast = self.forecast_get(html) rains = forecast.split('datetime=') for rain in rains[1:]: rain_match = re.findall(r'"([0-9\-]+)".+chance-value">([0-9]+%).+"chance-amount amount-[0-9\-]+">(.+)</b>', rain) if len(rain_match) > 0: rain_match = list(rain_match[0]) rain_match[2] = rain_match[2].replace('<', '<') rain_match[2] = rain_match[2].replace('>', '>') rain_match[2] = rain_match[2].replace(' ', ' ') rain_match[2] = rain_match[2].replace('–', '-') else: rain_match = re.findall(r'"([0-9\-]+)".+No Rain', rain) if len(rain_match) == 0: continue rain_match.append('0%') rain_match.append('0mm') rain_match[0] = util.time_get(rain_match[0]) self.rains.append(rain_match)
def __init__(self, uri): self.seatemps = [] html = util.html_get(uri) forecast_seatemp = self.forecast_get(html) temperatures = list(re.findall(r'([0-9.]+)', forecast_seatemp)) self.seatemps.append([self.time_get(), temperatures[0]])
def test(): html = util.html_get( r"http://seatemperature.net/current/australia/nelson-bay-new-south-wales-australia-sea-temperature" ) soup = BeautifulSoup(html, 'html.parser') templine = str(soup.find(id='temp1')) print(templine) m = re.search("<h3>([0-9.]+)", templine) if m: print(m.group(1))
def __init__(self, uri): self.winds = [] html = util.html_get(uri) forecast = self.forecast_get(html) datas = re.findall( r'{"x":([0-9]+),"y":([0-9.]+),"direction":[0-9]+,"directionText":"([NEWS]+)",', forecast) for data in datas: data_list = list(data) data_list[0] = int(data_list[0]) self.winds.append(data_list)
def __init__(self, uri): self.suns = [] html = util.html_get(uri) forecast = self.forecast_get(html) datas = re.findall(r'"x":([0-9]+),"description":"([A-Za-z ]+)"', forecast) for data in datas: list_data = list(data) list_data[0] = int(list_data[0]) self.suns.append(list_data)
def __init__(self, uri): html = util.html_get(uri) forecast_heights = self.forecast_heights_get(html) heights = self.heights_get(forecast_heights) forecast_periods = self.forecast_periods_get(html) periods = self.periods_get(forecast_periods) self.swells = self.merge(heights, periods)
def __init__(self, uri): self.moons = [] html = util.html_get(uri) forecast = self.forecast_get(html) moons = forecast.split('datetime=') for moon in moons: moon_match = re.findall(r'([0-9\-]+)".+data-fill="([0-9]+)"', moon) if len(moon_match) < 1: continue moon_list = list(moon_match[0]) moon_list[0] = util.time_get(moon_list[0]) self.moons.append(list(moon_list))