示例#1
0
 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)
示例#2
0
    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('&lt;', '<')
                rain_match[2] = rain_match[2].replace('&gt;', '>')
                rain_match[2] = rain_match[2].replace('&nbsp;', ' ')
                rain_match[2] = rain_match[2].replace('&ndash;', '-')
            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)
示例#3
0
    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]])
示例#4
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))
示例#5
0
 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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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))