{ "cells": [ { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "from bs4 import BeautifulSoup\n", "from bs4.element import Comment\n", "import urllib.request" ] }, { "cell_type": "code", "execution_count": 102, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " weather.gov Site Map News Organization Search for: SPC NCEP All NOAA Search by city or zip code. Press enter or select the go button to submit request Local forecast by \"City, St\" or \"ZIP\" SPC on Facebook @NWSSPC NCEP Quarterly Newsletter Home ( Classic ) SPC Products All SPC Forecasts Current Watches Meso. Discussions Conv. Outlooks Tstm. Outlooks Fire Wx Outlooks RSS Feeds E-Mail Alerts Weather Information Storm Reports Storm Reports Dev. NWS Hazards Map National RADAR Product Archive NOAA Weather Radio Research Non-op. Products Forecast Tools Svr. Tstm. Events SPC Publications SPC-NSSL HWT Education & Outreach About the SPC SPC FAQ About Tornadoes About Derechos Video Lecture Series WCM Page Enh. Fujita Page Our History Public Tours Misc. Staff Contact Us SPC Feedback Day 2 FW Outlook > Oct 27, 2020 Day 1 Fire Weather Outlook Updated: Tue Oct 27 06:08:03 UTC 2020 ( Print Version | | ) Day 1 Fire Pop. Cities CWAs RFCs Interstates Counties ARTCC FEMA Regions Day 1 Surface Analysis Risk Area (sq. mi.) Area Pop. Some Larger Population Centers in Risk Area Critical 29,878 14,484,626 Sacramento, CA...Santa Ana, CA...Anaheim, CA...Riverside, CA...Stockton, CA... ZCZC SPCFWDDY1 ALL\n", " FNUS21 KWNS 270607\n", "\n", " Day 1 Fire Weather Outlook \n", " NWS Storm Prediction Center Norman OK\n", " 0107 AM CDT Tue Oct 27 2020\n", "\n", " Valid 271200Z - 281200Z\n", "\n", " ...CRITICAL FIRE WEATHER AREA FOR PORTIONS OF NORTHERN CALIFORNIA...\n", " ...CRITICAL FIRE WEATHER AREA FOR PORTIONS OF SOUTHERN CALIFORNIA...\n", " ...CRITICAL FIRE WEATHER AREA FOR PORTIONS OF THE LOWER COLORADO\n", " RIVER VALLEY...\n", "\n", " ...Synopsis...\n", " Persistent surface ridging across a large part of the Intermountain\n", " West/Great Basin and surface troughing from the California coast\n", " southeastward through Baja California and the Lower Colorado River\n", " Valley will continue to foster elevated to critical fire-weather\n", " conditions in several areas across California, Nevada, and Arizona. \n", " Models do indicate that the gradient between these two synoptic\n", " features will slacken over the course of the forecast period and\n", " reduce surface wind speeds especially in northern California.\n", "\n", " ...Northern/central California...\n", " Over the course of the day, surface heating/vertical mixing and the\n", " existing pressure gradient across the area will once again increase\n", " wind speeds into the 20-35 mph range, with higher gusts (to 60 mph)\n", " expected in typical terrain-favored areas. The residing airmass is\n", " dry and will remain so throughout the period, with critically low RH\n", " values through the day (5-15%) and poor overnight recoveries. \n", " Elevated to critical fire weather remains likely - with critical\n", " highlights tied to areas of strongest surface winds.\n", "\n", " ...Southern California...\n", " The aforementioned offshore gradient will continue to maintain a\n", " very dry airmass across much of the region, with very poor overnight\n", " recovery resulting in critically low RH (5-15%) even at the start of\n", " the forecast period (12Z Tue). These dry conditions will persist\n", " throughout the day as temperatures warm into the 70s and low 80s F. \n", " Meanwhile, 25-35 mph northeasterly surface winds will develop\n", " through the day, with gusts perhaps exceeding 60 mph especially in\n", " terrain-favored areas. Fuels remain dry across the region and\n", " support of fire spread. Elevated and critical delineations remain\n", " in place to address the aforementioned scenario.\n", "\n", " ...Lower Colorado River Valley...\n", " Latest models (and particularly high-resolution guidance) depict\n", " areas of gusty northerly winds in the vicinity of the Lower Colorado\n", " River that will strengthen into the 20-25 mph range with higher\n", " gusts. These winds will occur within a dry airmass, with widespread\n", " single-digit RH values expected during the afternoon as temperatures\n", " rise into the 70s and 80s F. Dry fuel beds will potentially carry\n", " large fires. Thus, the critical delineation has been added.\n", "\n", " ..Cook.. 10/27/2020\n", "\n", " ...Please see www.spc.noaa.gov/fire for graphic product...\n", "\n", " CLICK FOR DAY 1 FIREWX AREAL OUTLINE PRODUCT (KWNSPFWFD1) Related Fire Weather Web Links Top / Forecast Products / Home Weather Topics: Watches , Mesoscale Discussions , Outlooks , Fire Weather , All Products , Contact Us NOAA / National Weather Service National Centers for Environmental Prediction Storm Prediction Center 120 David L. Boren Blvd. Norman, OK 73072 U.S.A. spc.feedback@noaa.gov Page last modified:\n", "\n", "\n", "October 27, 2020 Disclaimer Information Quality Help Glossary Privacy Policy Freedom of Information Act (FOIA) About Us Career Opportunities \n" ] } ], "source": [ "url = \"https://www.spc.noaa.gov/products/fire_wx/fwdy1.html\"\n", "\n", "def tag_visible(element):\n", " if element.parent.name in ['style', 'script', 'head', 'title', 'meta', '[document]']:\n", " return False\n", " if isinstance(element, Comment):\n", " return False\n", " return True\n", "\n", "\n", "def text_from_html(body):\n", " soup = BeautifulSoup(body, 'html.parser')\n", " texts = soup.findAll(text=True)\n", " visible_texts = filter(tag_visible, texts) \n", " return u\" \".join(t.strip() for t in visible_texts)\n", "\n", "html = urllib.request.urlopen(url).read()\n", "wx = text_from_html(html)\n", "\n", "a = wx.splitlines()\n", "wxemail = []\n", "\n", "for x in a:\n", " x = str(x)\n", " print(x)\n", " wxemail.append(x)" ] }, { "cell_type": "code", "execution_count": 103, "metadata": {}, "outputs": [], "source": [ "def send_email(user, pwd, recipient, subject, body):\n", "\timport smtplib\n", "\tbody.encode('ascii',errors='ignore')\n", "\tbody.encode('utf-8',errors='replace')\n", "\tbody=body.encode('ascii','ignore').decode('ascii')\n", "\tgmail_user = user\n", "\tgmail_pwd = pwd\n", "\tFROM = user\n", "\tTO = recipient if type(recipient) is list else [recipient]\n", "\tSUBJECT = subject\n", "\tTEXT = body\n", "\n", "\t# Prepare actual message\n", "\tmessage = \"\"\"From: %s\\nTo: %s\\nSubject: %s\\n\\n%s\n", "\t\"\"\" % (FROM, \", \".join(TO), SUBJECT, TEXT)\n", "\ttry:\n", "\t\tserver = smtplib.SMTP(\"10.12.112.10\", 25)\n", "\t\t#server = smtplib.SMTP(\"192.31.208.52\",443)\n", "\t\t#server.ehlo()\n", "\t\t#server.starttls()\n", "\t\t#server.login(gmail_user, gmail_pwd)\n", "\t\tserver.sendmail(FROM, TO, message)\n", "\t\tserver.close()\n", "\t\tprint('successfully sent the email')\n", "\texcept Exception as ex:\n", "\t\tprint(\"failed to send mail\")\n", "\t\tprint(ex)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "send_email('fireline@verisk.com', '', ['kaitlyn.perham@verisk.com'], 'WildfireWeather',\"\\n\".join(str(x) for x in wxemail))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.2" } }, "nbformat": 4, "nbformat_minor": 2 }