from time import sleep
for i in range(5):
print(i)
sleep(2)
0 1 2 3 4
"""
<record type="book">
<author>Camus, Albert</author>
<title>Plague</title>
</record>
"""
'\n<record type="book">\n<author>Camus, Albert</author>\n<title>Plague</title>\n</record>\n'
from zipfile import ZipFile
with ZipFile('excel_sample.xlsx', 'r') as z:
z.extractall(path='excel_sample')
dodeca = "https://upload.wikimedia.org/wikipedia/commons/a/a4/Dodecahedron.svg"
import requests
r = requests.get(dodeca)
r.request.headers
{'User-Agent': 'python-requests/2.27.1', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}
r = requests.get(dodeca,
headers={'User-Agent': 'MTH448/548 script 1.0'})
r.request.headers
{'User-Agent': 'MTH448/548 script 1.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}
import requests
r = requests.get(dodeca)
print(r.text[:1000])
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="300" height="300" id="svg2" sodipodi:version="0.32" inkscape:version="0.46" sodipodi:docname="pentagon.svg" inkscape:output_extension="org.inkscape.output.svg.inkscape" version="1.0"> <defs id="defs4"> <linearGradient inkscape:collect="always" id="linearGradient9218"> <stop style="stop-color:#0c4c31;stop-opacity:1" offset="0" id="stop9220" /> <stop style="stop-col
from IPython.display import display, SVG
display(SVG(r.text))
pic = """
<svg width="500" height="300">
<circle cx = "100"
cy = "100"
r = "50"
stroke = "red"
fill = "lime"
stroke-width = "4"
/>
<rect x = "100"
y = "100"
width = "100"
height = "100"
stroke = "red"
fill = "blue"
stroke-width = "4"
fill-opacity = "0.5"
/>
<text x="200" y = "100" font-size = "50px">Hello there!!!</text>
</svg>
"""
display(SVG(pic))
%pip install lxml
Requirement already satisfied: lxml in /Users/bb/opt/anaconda3/lib/python3.8/site-packages (4.7.1) Note: you may need to restart the kernel to use updated packages.
import lxml
from bs4 import BeautifulSoup
soup = BeautifulSoup(pic, "xml")
soup
<?xml version="1.0" encoding="utf-8"?> <svg height="300" width="500"> <circle cx="100" cy="100" fill="lime" r="50" stroke="red" stroke-width="4"/> <rect fill="blue" fill-opacity="0.5" height="100" stroke="red" stroke-width="4" width="100" x="100" y="100"/> <text font-size="50px" x="200" y="100">Hello there!!!</text> </svg>
soup.find('text').get_text()
'Hello there!!!'
soup = BeautifulSoup("", "xml")
soup
<?xml version="1.0" encoding="utf-8"?>
t = soup.new_tag("svg", width=1000, heigth=100)
t
<svg heigth="100" width="1000"/>
soup.append(t)
soup
<?xml version="1.0" encoding="utf-8"?> <svg heigth="100" width="1000"/>
t = soup.new_tag("circle", cx=100, cy=50, r=50, fill="red")
t
<circle cx="100" cy="50" fill="red" r="50"/>
svg = soup.find("svg")
svg
<svg heigth="100" width="1000"/>
svg.append(t)
soup
<?xml version="1.0" encoding="utf-8"?> <svg heigth="100" width="1000"><circle cx="100" cy="50" fill="red" r="50"/></svg>
display(SVG(str(soup)))
circle = soup.find('circle')
circle
<circle cx="100" cy="50" fill="red" r="50"/>
circle["cx"] = 200
soup
<?xml version="1.0" encoding="utf-8"?> <svg heigth="100" width="1000"><circle cx="200" cy="50" fill="red" r="50"/></svg>
display(SVG(str(soup)))
from IPython.display import clear_output
for i in range(1000):
circle['cx'] = i
display(SVG(str(soup)))
clear_output(wait=True)
counties = "https://upload.wikimedia.org/wikipedia/commons/5/59/Usa_counties_large.svg"
import requests
r = requests.get(counties, headers={'User-Agent': 'MTH448/548 script 1.0'})
from IPython.display import display, SVG
display(SVG(r.text))
r.text[:1000]
'<?xml version="1.0" encoding="UTF-8"?>\n<svg width="989.98" height="627.07" version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\n <metadata>\n <rdf:RDF>\n <cc:Work>\n <dc:format>image/svg+xml</dc:format>\n <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>\n <dc:title/>\n <cc:license rdf:resource="http://creativecommons.org/publicdomain/zero/1.0/"/>\n <dc:date>2019-10-06</dc:date>\n <dc:creator>\n <cc:Agent>\n <dc:title>U.S. Census Bureau, Abe.suleiman, Lokal_Profil</dc:title>\n </cc:Agent>\n </dc:creator>\n <dc:source>https://commons.wikimedia.org/wiki/File:Usa_counties_large.svg</dc:source>\n </cc:Work>\n <cc:License rdf:about="http://creativecommons.org/publicdomain/zero/1.0/">\n <cc:permits rdf:resource="http://creativecommons.org/ns#Reproduction"/>\n <cc:permits rdf:resource="http://creativecommons.'
soup = BeautifulSoup(r.text)
counties = [p for p in soup.find_all("path") if p.find("title")]
counties[100]
<path d="m582.41 364.07 0.0481 3.101-0.65253 0.934 0.041 2 0.073 6.294-0.66896 0.0594-2.3694 0.255 0.31403 1.1963-0.71382-0.0759-2.831-3.4634-1.6555-0.6564-0.39045-0.218-0.0428-3.302h0.33875l1.0038-1.059 0.95561-1.955-0.0303-3.037 3.9526-0.02 2.628-0.04" id="c05115" style="stroke:#000"> <title>Pope, AR</title> </path>
erie = [p for p in counties if p.title.get_text() == "Erie, NY"][0]
erie
<path d="m815.28 167.46 0.93065 5.013-0.36192 0.07 0.33696 1.985 0.41898-0.07 1.0216 5.553-2.1448 0.981-1.8488 0.989-1.9237 1.277-0.40828 0.168-0.41006 0.105-0.98771-0.507-2.1965-1.237-0.38418-0.67809-1.0029 0.18809 0.0321-0.483 0.2086-0.596 0.72206-1.902 0.45107-0.378 1.1089-0.916 0.41185-0.193 0.68818-0.9 0.19434-0.362v-0.184l-0.60261-1.334-0.94136-1.704-0.21751-0.282-0.25495-0.16-0.70958-0.128-0.72206-0.305-0.17651-0.193-0.13728-0.499-0.29774-1.109 1.3692-0.257 1.1523 1.1869 0.80804-0.12114 0.7392-1.3603 3.011-0.87842 1.7436-0.57 0.37976-0.202" id="c36029" style="stroke:#000"> <title>Erie, NY</title> </path>
erie["fill"] = "red"
display(SVG(str(soup)))
erie
<path d="m815.28 167.46 0.93065 5.013-0.36192 0.07 0.33696 1.985 0.41898-0.07 1.0216 5.553-2.1448 0.981-1.8488 0.989-1.9237 1.277-0.40828 0.168-0.41006 0.105-0.98771-0.507-2.1965-1.237-0.38418-0.67809-1.0029 0.18809 0.0321-0.483 0.2086-0.596 0.72206-1.902 0.45107-0.378 1.1089-0.916 0.41185-0.193 0.68818-0.9 0.19434-0.362v-0.184l-0.60261-1.334-0.94136-1.704-0.21751-0.282-0.25495-0.16-0.70958-0.128-0.72206-0.305-0.17651-0.193-0.13728-0.499-0.29774-1.109 1.3692-0.257 1.1523 1.1869 0.80804-0.12114 0.7392-1.3603 3.011-0.87842 1.7436-0.57 0.37976-0.202" fill="red" id="c36029" style="stroke:#000"> <title>Erie, NY</title> </path>
for c in counties[:100]:
print(c.title.get_text())
Prince William, VA Manassas Park, VA North Slope, AK Northwest Arctic, AK Prince of Wales-Hyder, AK Ketchikan Gateway, AK Wrangell, AK Petersburg, AK Sitka, AK Haines, AK Juneau, AK Skagway, AK Hoonah-Angoon, AK Yakutat, AK Aleutians West, AK Aleutians East, AK Kodiak Island, AK Bristol Bay, AK Dillingham, AK Lake and Peninsula, AK Kenai Peninsula, AK Anchorage, AK Valdez-Cordova, AK Matanuska-Susitna, AK Southeast Fairbanks, AK Fairbanks North Star, AK Denali, AK Bethel, AK Kusilvak, AK Nome, AK Yukon-Koyukuk, AK Houston, AL Henry, AL Geneva, AL Dale, AL Coffee, AL Covington, AL Mobile, AL Baldwin, AL Escambia, AL Conecuh, AL Washington, AL Choctaw, AL Clarke, AL Monroe, AL Wilcox, AL Butler, AL Crenshaw, AL Pike, AL Bullock, AL Macon, AL Lowndes, AL Montgomery, AL Elmore, AL Autauga, AL Dallas, AL Marengo, AL Sumter, AL Perry, AL Chilton, AL Coosa, AL Tallapoosa, AL Clay, AL Talladega, AL Shelby, AL Bibb, AL Hale, AL Greene, AL Pickens, AL Tuscaloosa, AL Jefferson, AL Walker, AL Lamar, AL Fayette, AL Franklin, AL Marion, AL Winston, AL Cullman, AL Blount, AL St. Clair, AL Calhoun, AL Etowah, AL Marshall, AL Morgan, AL Lawrence, AL Colbert, AL Lauderdale, AL Limestone, AL Madison, AL Jackson, AL DeKalb, AL Cherokee, AL Cleburne, AL Randolph, AL Chambers, AL Lee, AL Russell, AL Barbour, AL Chicot, AR Ashley, AR
import requests
alerts_url = "https://api.weather.gov/alerts/active"
params = {'area': 'NY'}
headers = {'Accept': 'application/atom+xml', "User-Agent": "UB Math 448/548"}
r = requests.get(alerts_url, headers=headers, params=params)
r.request.headers
{'User-Agent': 'UB Math 448/548', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': 'application/atom+xml', 'Connection': 'keep-alive'}
r.request.url
'https://api.weather.gov/alerts/active?area=NY&severity=severe'
print(r.text)
<?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:cap="urn:oasis:names:tc:emergency:cap:1.2"> <id>https://api.weather.gov/alerts?area%5B0%5D=NY&active=1</id> <generator>NWS CAP Server</generator> <updated>2022-03-30T13:37:33+00:00</updated> <author> <name>w-nws.webmaster@noaa.gov</name> </author> <title>current watches, warnings, and advisories for New York</title> <link rel="self" href="https://api.weather.gov/alerts?area%5B0%5D=NY&active=1"/> <entry> <id>https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.001.1</id> <link rel="alternate" href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.001.1"/> <updated>2022-03-30T09:37:00-04:00</updated> <published>2022-03-30T09:37:00-04:00</published> <author> <name>NWS</name> </author> <title>Winter Weather Advisory issued March 30 at 9:37AM EDT until March 30 at 1:00PM EDT by NWS Buffalo NY</title> <summary>* WHAT...Freezing rain. Additional ice accumulations of a few hundredths of an inch. * WHERE...Chautauqua, Cattaraugus, and Southern Erie counties. * WHEN...Until 1 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. The hazardous conditions could impact the morning commute.</summary> <cap:event>Winter Weather Advisory</cap:event> <cap:sent>2022-03-30T09:37:00-04:00</cap:sent> <cap:effective>2022-03-30T09:37:00-04:00</cap:effective> <cap:onset>2022-03-30T09:37:00-04:00</cap:onset> <cap:expires>2022-03-30T13:00:00-04:00</cap:expires> <cap:status>Actual</cap:status> <cap:msgType>Update</cap:msgType> <cap:category>Met</cap:category> <cap:urgency>Expected</cap:urgency> <cap:severity>Moderate</cap:severity> <cap:certainty>Likely</cap:certainty> <cap:areaDesc>Chautauqua; Cattaraugus; Southern Erie</cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName>SAME</valueName> <value>036013</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036009</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036029</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ019</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ020</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ085</value> </cap:geocode> <cap:parameter> <valueName>AWIPSidentifier</valueName> <value>WSWBUF</value> </cap:parameter> <cap:parameter> <valueName>WMOidentifier</valueName> <value>WWUS41 KBUF 301337</value> </cap:parameter> <cap:parameter> <valueName>NWSheadline</valueName> <value>WINTER WEATHER ADVISORY REMAINS IN EFFECT UNTIL 1 PM EDT THIS AFTERNOON</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>EAS</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>NWEM</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>CMAS</value> </cap:parameter> <cap:parameter> <valueName>VTEC</valueName> <value>/O.CON.KBUF.WW.Y.0021.000000T0000Z-220330T1700Z/</value> </cap:parameter> <cap:parameter> <valueName>eventEndingTime</valueName> <value>2022-03-30T17:00:00+00:00</value> </cap:parameter> <cap:parameter> <valueName>expiredReferences</valueName> <value>w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.fb417b8a5f3d3ca30a74ead13b89475cfd6b1e93.001.1,2022-03-29T21:58:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.5636dcaa2c8b053113bcfb1fb3a80eb99bc68cb2.001.1,2022-03-29T13:35:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.002.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.001.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.d6432c96f6101e9d1b6d5fb0e338856f727a922d.001.1,2021-11-19T09:23:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.001.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.002.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.002.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.001.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.001.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.002.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.001.1,2021-11-18T03:14:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.002.1,2021-11-18T03:14:00-05:00</value> </cap:parameter> </entry> <entry> <id>https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.002.1</id> <link rel="alternate" href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.002.1"/> <updated>2022-03-30T09:37:00-04:00</updated> <published>2022-03-30T09:37:00-04:00</published> <author> <name>NWS</name> </author> <title>Winter Weather Advisory issued March 30 at 9:37AM EDT until March 30 at 1:00PM EDT by NWS Buffalo NY</title> <summary>* WHAT...Freezing rain. Additional ice accumulations of a few hundredths of an inch. * WHERE...Wyoming, Livingston, Ontario, and Allegany counties. * WHEN...Until 1 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. The hazardous conditions could impact the morning commute.</summary> <cap:event>Winter Weather Advisory</cap:event> <cap:sent>2022-03-30T09:37:00-04:00</cap:sent> <cap:effective>2022-03-30T09:37:00-04:00</cap:effective> <cap:onset>2022-03-30T09:37:00-04:00</cap:onset> <cap:expires>2022-03-30T13:00:00-04:00</cap:expires> <cap:status>Actual</cap:status> <cap:msgType>Update</cap:msgType> <cap:category>Met</cap:category> <cap:urgency>Expected</cap:urgency> <cap:severity>Moderate</cap:severity> <cap:certainty>Likely</cap:certainty> <cap:areaDesc>Wyoming; Livingston; Ontario; Allegany</cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName>SAME</valueName> <value>036121</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036051</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036069</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036003</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ012</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ013</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ014</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ021</value> </cap:geocode> <cap:parameter> <valueName>AWIPSidentifier</valueName> <value>WSWBUF</value> </cap:parameter> <cap:parameter> <valueName>WMOidentifier</valueName> <value>WWUS41 KBUF 301337</value> </cap:parameter> <cap:parameter> <valueName>NWSheadline</valueName> <value>WINTER WEATHER ADVISORY REMAINS IN EFFECT UNTIL 1 PM EDT THIS AFTERNOON</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>EAS</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>NWEM</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>CMAS</value> </cap:parameter> <cap:parameter> <valueName>VTEC</valueName> <value>/O.CON.KBUF.WW.Y.0021.000000T0000Z-220330T1700Z/</value> </cap:parameter> <cap:parameter> <valueName>eventEndingTime</valueName> <value>2022-03-30T17:00:00+00:00</value> </cap:parameter> <cap:parameter> <valueName>expiredReferences</valueName> <value>w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.fb417b8a5f3d3ca30a74ead13b89475cfd6b1e93.001.1,2022-03-29T21:58:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.5636dcaa2c8b053113bcfb1fb3a80eb99bc68cb2.001.1,2022-03-29T13:35:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.001.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.d6432c96f6101e9d1b6d5fb0e338856f727a922d.001.1,2021-11-19T09:23:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.001.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.001.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.001.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.001.1,2021-11-18T03:14:00-05:00</value> </cap:parameter> </entry> <entry> <id>https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.95ae44eac7d37c0d88df03a0edb0e9261f04c493.001.1</id> <link rel="alternate" href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.95ae44eac7d37c0d88df03a0edb0e9261f04c493.001.1"/> <updated>2022-03-30T09:35:00-04:00</updated> <published>2022-03-30T09:35:00-04:00</published> <author> <name>NWS</name> </author> <title>Wind Advisory issued March 30 at 9:35AM EDT until March 31 at 10:00AM EDT by NWS Buffalo NY</title> <summary>* WHAT...South winds 25 to 35 mph with gusts up to 50 mph expected. * WHERE...Chautauqua and Southern Erie counties. Strongest winds along the Lake Erie shore and north facing slopes. * WHEN...From 8 PM this evening to 10 AM EDT Thursday. * IMPACTS...Gusty winds could blow around unsecured objects. Tree limbs could be blown down and a few isolated power outages may result.</summary> <cap:event>Wind Advisory</cap:event> <cap:sent>2022-03-30T09:35:00-04:00</cap:sent> <cap:effective>2022-03-30T09:35:00-04:00</cap:effective> <cap:onset>2022-03-30T20:00:00-04:00</cap:onset> <cap:expires>2022-03-30T18:00:00-04:00</cap:expires> <cap:status>Actual</cap:status> <cap:msgType>Update</cap:msgType> <cap:category>Met</cap:category> <cap:urgency>Expected</cap:urgency> <cap:severity>Moderate</cap:severity> <cap:certainty>Likely</cap:certainty> <cap:areaDesc>Chautauqua; Southern Erie</cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName>SAME</valueName> <value>036013</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036029</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ019</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ085</value> </cap:geocode> <cap:parameter> <valueName>AWIPSidentifier</valueName> <value>NPWBUF</value> </cap:parameter> <cap:parameter> <valueName>WMOidentifier</valueName> <value>WWUS71 KBUF 301335</value> </cap:parameter> <cap:parameter> <valueName>NWSheadline</valueName> <value>WIND ADVISORY REMAINS IN EFFECT FROM 8 PM THIS EVENING TO 10 AM EDT THURSDAY</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>EAS</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>NWEM</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>CMAS</value> </cap:parameter> <cap:parameter> <valueName>VTEC</valueName> <value>/O.CON.KBUF.WI.Y.0005.220331T0000Z-220331T1400Z/</value> </cap:parameter> <cap:parameter> <valueName>eventEndingTime</valueName> <value>2022-03-31T14:00:00+00:00</value> </cap:parameter> <cap:parameter> <valueName>expiredReferences</valueName> <value>w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.5b8729d0d7c7ae85e0fc9736f7b145bcfbb13c4a.001.1,2021-03-28T21:57:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.ee572c08962219c99582e7dfd7fc29349d52ce47.001.1,2021-03-29T06:41:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.8ee75c629b6bebf7a9cc6da3fa9f0251b6f8dfd1.001.1,2021-03-28T17:02:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.dde840aa29c9c7f30301661834e051301b390911.001.1,2021-03-28T11:25:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.f6810f282bcf503ca478dba47e1c3e48dc4930f1.001.1,2021-03-28T04:00:00-04:00</value> </cap:parameter> </entry> <entry> <id>https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.d7981b9af8047c69d2551b0777aa68fd48efb6c4.001.1</id> <link rel="alternate" href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.d7981b9af8047c69d2551b0777aa68fd48efb6c4.001.1"/> <updated>2022-03-30T03:51:00-04:00</updated> <published>2022-03-30T03:51:00-04:00</published> <author> <name>NWS</name> </author> <title>Winter Weather Advisory issued March 30 at 3:51AM EDT until March 30 at 2:00PM EDT by NWS Binghamton NY</title> <summary>* WHAT...Mixed precipitation expected. Total snow accumulations of up to one inch and ice accumulations of a light glaze. * WHERE...In Pennsylvania, Bradford county. In New York, Chemung, Yates, Schuyler and Steuben counties. * WHEN...From 8 AM this morning to 2 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions.</summary> <cap:event>Winter Weather Advisory</cap:event> <cap:sent>2022-03-30T03:51:00-04:00</cap:sent> <cap:effective>2022-03-30T03:51:00-04:00</cap:effective> <cap:onset>2022-03-30T08:00:00-04:00</cap:onset> <cap:expires>2022-03-30T14:00:00-04:00</cap:expires> <cap:status>Actual</cap:status> <cap:msgType>Update</cap:msgType> <cap:category>Met</cap:category> <cap:urgency>Expected</cap:urgency> <cap:severity>Moderate</cap:severity> <cap:certainty>Likely</cap:certainty> <cap:areaDesc>Yates; Steuben; Schuyler; Chemung; Bradford</cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName>SAME</valueName> <value>036123</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036101</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036097</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036015</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>042015</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ015</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ022</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ023</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ024</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>PAZ038</value> </cap:geocode> <cap:parameter> <valueName>AWIPSidentifier</valueName> <value>WSWBGM</value> </cap:parameter> <cap:parameter> <valueName>WMOidentifier</valueName> <value>WWUS41 KBGM 300751</value> </cap:parameter> <cap:parameter> <valueName>NWSheadline</valueName> <value>WINTER WEATHER ADVISORY REMAINS IN EFFECT FROM 8 AM THIS MORNING TO 2 PM EDT THIS AFTERNOON</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>EAS</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>NWEM</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>CMAS</value> </cap:parameter> <cap:parameter> <valueName>VTEC</valueName> <value>/O.CON.KBGM.WW.Y.0019.220330T1200Z-220330T1800Z/</value> </cap:parameter> <cap:parameter> <valueName>eventEndingTime</valueName> <value>2022-03-30T18:00:00+00:00</value> </cap:parameter> </entry> </feed>
from bs4 import BeautifulSoup
soup = BeautifulSoup(r.text, "xml")
print(soup.prettify())
<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:cap="urn:oasis:names:tc:emergency:cap:1.2"> <id> https://api.weather.gov/alerts?area%5B0%5D=NY&active=1 </id> <generator> NWS CAP Server </generator> <updated> 2022-03-30T13:37:33+00:00 </updated> <author> <name> w-nws.webmaster@noaa.gov </name> </author> <title> current watches, warnings, and advisories for New York </title> <link href="https://api.weather.gov/alerts?area%5B0%5D=NY&active=1" rel="self"/> <entry> <id> https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.001.1 </id> <link href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.001.1" rel="alternate"/> <updated> 2022-03-30T09:37:00-04:00 </updated> <published> 2022-03-30T09:37:00-04:00 </published> <author> <name> NWS </name> </author> <title> Winter Weather Advisory issued March 30 at 9:37AM EDT until March 30 at 1:00PM EDT by NWS Buffalo NY </title> <summary> * WHAT...Freezing rain. Additional ice accumulations of a few hundredths of an inch. * WHERE...Chautauqua, Cattaraugus, and Southern Erie counties. * WHEN...Until 1 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. The hazardous conditions could impact the morning commute. </summary> <cap:event> Winter Weather Advisory </cap:event> <cap:sent> 2022-03-30T09:37:00-04:00 </cap:sent> <cap:effective> 2022-03-30T09:37:00-04:00 </cap:effective> <cap:onset> 2022-03-30T09:37:00-04:00 </cap:onset> <cap:expires> 2022-03-30T13:00:00-04:00 </cap:expires> <cap:status> Actual </cap:status> <cap:msgType> Update </cap:msgType> <cap:category> Met </cap:category> <cap:urgency> Expected </cap:urgency> <cap:severity> Moderate </cap:severity> <cap:certainty> Likely </cap:certainty> <cap:areaDesc> Chautauqua; Cattaraugus; Southern Erie </cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName> SAME </valueName> <value> 036013 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 036009 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 036029 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ019 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ020 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ085 </value> </cap:geocode> <cap:parameter> <valueName> AWIPSidentifier </valueName> <value> WSWBUF </value> </cap:parameter> <cap:parameter> <valueName> WMOidentifier </valueName> <value> WWUS41 KBUF 301337 </value> </cap:parameter> <cap:parameter> <valueName> NWSheadline </valueName> <value> WINTER WEATHER ADVISORY REMAINS IN EFFECT UNTIL 1 PM EDT THIS AFTERNOON </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> EAS </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> NWEM </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> CMAS </value> </cap:parameter> <cap:parameter> <valueName> VTEC </valueName> <value> /O.CON.KBUF.WW.Y.0021.000000T0000Z-220330T1700Z/ </value> </cap:parameter> <cap:parameter> <valueName> eventEndingTime </valueName> <value> 2022-03-30T17:00:00+00:00 </value> </cap:parameter> <cap:parameter> <valueName> expiredReferences </valueName> <value> w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.fb417b8a5f3d3ca30a74ead13b89475cfd6b1e93.001.1,2022-03-29T21:58:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.5636dcaa2c8b053113bcfb1fb3a80eb99bc68cb2.001.1,2022-03-29T13:35:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.002.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.001.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.d6432c96f6101e9d1b6d5fb0e338856f727a922d.001.1,2021-11-19T09:23:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.001.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.002.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.002.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.001.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.001.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.002.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.001.1,2021-11-18T03:14:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.002.1,2021-11-18T03:14:00-05:00 </value> </cap:parameter> </entry> <entry> <id> https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.002.1 </id> <link href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.002.1" rel="alternate"/> <updated> 2022-03-30T09:37:00-04:00 </updated> <published> 2022-03-30T09:37:00-04:00 </published> <author> <name> NWS </name> </author> <title> Winter Weather Advisory issued March 30 at 9:37AM EDT until March 30 at 1:00PM EDT by NWS Buffalo NY </title> <summary> * WHAT...Freezing rain. Additional ice accumulations of a few hundredths of an inch. * WHERE...Wyoming, Livingston, Ontario, and Allegany counties. * WHEN...Until 1 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. The hazardous conditions could impact the morning commute. </summary> <cap:event> Winter Weather Advisory </cap:event> <cap:sent> 2022-03-30T09:37:00-04:00 </cap:sent> <cap:effective> 2022-03-30T09:37:00-04:00 </cap:effective> <cap:onset> 2022-03-30T09:37:00-04:00 </cap:onset> <cap:expires> 2022-03-30T13:00:00-04:00 </cap:expires> <cap:status> Actual </cap:status> <cap:msgType> Update </cap:msgType> <cap:category> Met </cap:category> <cap:urgency> Expected </cap:urgency> <cap:severity> Moderate </cap:severity> <cap:certainty> Likely </cap:certainty> <cap:areaDesc> Wyoming; Livingston; Ontario; Allegany </cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName> SAME </valueName> <value> 036121 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 036051 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 036069 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 036003 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ012 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ013 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ014 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ021 </value> </cap:geocode> <cap:parameter> <valueName> AWIPSidentifier </valueName> <value> WSWBUF </value> </cap:parameter> <cap:parameter> <valueName> WMOidentifier </valueName> <value> WWUS41 KBUF 301337 </value> </cap:parameter> <cap:parameter> <valueName> NWSheadline </valueName> <value> WINTER WEATHER ADVISORY REMAINS IN EFFECT UNTIL 1 PM EDT THIS AFTERNOON </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> EAS </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> NWEM </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> CMAS </value> </cap:parameter> <cap:parameter> <valueName> VTEC </valueName> <value> /O.CON.KBUF.WW.Y.0021.000000T0000Z-220330T1700Z/ </value> </cap:parameter> <cap:parameter> <valueName> eventEndingTime </valueName> <value> 2022-03-30T17:00:00+00:00 </value> </cap:parameter> <cap:parameter> <valueName> expiredReferences </valueName> <value> w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.fb417b8a5f3d3ca30a74ead13b89475cfd6b1e93.001.1,2022-03-29T21:58:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.5636dcaa2c8b053113bcfb1fb3a80eb99bc68cb2.001.1,2022-03-29T13:35:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.001.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.d6432c96f6101e9d1b6d5fb0e338856f727a922d.001.1,2021-11-19T09:23:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.001.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.001.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.001.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.001.1,2021-11-18T03:14:00-05:00 </value> </cap:parameter> </entry> <entry> <id> https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.95ae44eac7d37c0d88df03a0edb0e9261f04c493.001.1 </id> <link href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.95ae44eac7d37c0d88df03a0edb0e9261f04c493.001.1" rel="alternate"/> <updated> 2022-03-30T09:35:00-04:00 </updated> <published> 2022-03-30T09:35:00-04:00 </published> <author> <name> NWS </name> </author> <title> Wind Advisory issued March 30 at 9:35AM EDT until March 31 at 10:00AM EDT by NWS Buffalo NY </title> <summary> * WHAT...South winds 25 to 35 mph with gusts up to 50 mph expected. * WHERE...Chautauqua and Southern Erie counties. Strongest winds along the Lake Erie shore and north facing slopes. * WHEN...From 8 PM this evening to 10 AM EDT Thursday. * IMPACTS...Gusty winds could blow around unsecured objects. Tree limbs could be blown down and a few isolated power outages may result. </summary> <cap:event> Wind Advisory </cap:event> <cap:sent> 2022-03-30T09:35:00-04:00 </cap:sent> <cap:effective> 2022-03-30T09:35:00-04:00 </cap:effective> <cap:onset> 2022-03-30T20:00:00-04:00 </cap:onset> <cap:expires> 2022-03-30T18:00:00-04:00 </cap:expires> <cap:status> Actual </cap:status> <cap:msgType> Update </cap:msgType> <cap:category> Met </cap:category> <cap:urgency> Expected </cap:urgency> <cap:severity> Moderate </cap:severity> <cap:certainty> Likely </cap:certainty> <cap:areaDesc> Chautauqua; Southern Erie </cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName> SAME </valueName> <value> 036013 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 036029 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ019 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ085 </value> </cap:geocode> <cap:parameter> <valueName> AWIPSidentifier </valueName> <value> NPWBUF </value> </cap:parameter> <cap:parameter> <valueName> WMOidentifier </valueName> <value> WWUS71 KBUF 301335 </value> </cap:parameter> <cap:parameter> <valueName> NWSheadline </valueName> <value> WIND ADVISORY REMAINS IN EFFECT FROM 8 PM THIS EVENING TO 10 AM EDT THURSDAY </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> EAS </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> NWEM </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> CMAS </value> </cap:parameter> <cap:parameter> <valueName> VTEC </valueName> <value> /O.CON.KBUF.WI.Y.0005.220331T0000Z-220331T1400Z/ </value> </cap:parameter> <cap:parameter> <valueName> eventEndingTime </valueName> <value> 2022-03-31T14:00:00+00:00 </value> </cap:parameter> <cap:parameter> <valueName> expiredReferences </valueName> <value> w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.5b8729d0d7c7ae85e0fc9736f7b145bcfbb13c4a.001.1,2021-03-28T21:57:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.ee572c08962219c99582e7dfd7fc29349d52ce47.001.1,2021-03-29T06:41:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.8ee75c629b6bebf7a9cc6da3fa9f0251b6f8dfd1.001.1,2021-03-28T17:02:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.dde840aa29c9c7f30301661834e051301b390911.001.1,2021-03-28T11:25:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.f6810f282bcf503ca478dba47e1c3e48dc4930f1.001.1,2021-03-28T04:00:00-04:00 </value> </cap:parameter> </entry> <entry> <id> https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.d7981b9af8047c69d2551b0777aa68fd48efb6c4.001.1 </id> <link href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.d7981b9af8047c69d2551b0777aa68fd48efb6c4.001.1" rel="alternate"/> <updated> 2022-03-30T03:51:00-04:00 </updated> <published> 2022-03-30T03:51:00-04:00 </published> <author> <name> NWS </name> </author> <title> Winter Weather Advisory issued March 30 at 3:51AM EDT until March 30 at 2:00PM EDT by NWS Binghamton NY </title> <summary> * WHAT...Mixed precipitation expected. Total snow accumulations of up to one inch and ice accumulations of a light glaze. * WHERE...In Pennsylvania, Bradford county. In New York, Chemung, Yates, Schuyler and Steuben counties. * WHEN...From 8 AM this morning to 2 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. </summary> <cap:event> Winter Weather Advisory </cap:event> <cap:sent> 2022-03-30T03:51:00-04:00 </cap:sent> <cap:effective> 2022-03-30T03:51:00-04:00 </cap:effective> <cap:onset> 2022-03-30T08:00:00-04:00 </cap:onset> <cap:expires> 2022-03-30T14:00:00-04:00 </cap:expires> <cap:status> Actual </cap:status> <cap:msgType> Update </cap:msgType> <cap:category> Met </cap:category> <cap:urgency> Expected </cap:urgency> <cap:severity> Moderate </cap:severity> <cap:certainty> Likely </cap:certainty> <cap:areaDesc> Yates; Steuben; Schuyler; Chemung; Bradford </cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName> SAME </valueName> <value> 036123 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 036101 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 036097 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 036015 </value> </cap:geocode> <cap:geocode> <valueName> SAME </valueName> <value> 042015 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ015 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ022 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ023 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> NYZ024 </value> </cap:geocode> <cap:geocode> <valueName> UGC </valueName> <value> PAZ038 </value> </cap:geocode> <cap:parameter> <valueName> AWIPSidentifier </valueName> <value> WSWBGM </value> </cap:parameter> <cap:parameter> <valueName> WMOidentifier </valueName> <value> WWUS41 KBGM 300751 </value> </cap:parameter> <cap:parameter> <valueName> NWSheadline </valueName> <value> WINTER WEATHER ADVISORY REMAINS IN EFFECT FROM 8 AM THIS MORNING TO 2 PM EDT THIS AFTERNOON </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> EAS </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> NWEM </value> </cap:parameter> <cap:parameter> <valueName> BLOCKCHANNEL </valueName> <value> CMAS </value> </cap:parameter> <cap:parameter> <valueName> VTEC </valueName> <value> /O.CON.KBGM.WW.Y.0019.220330T1200Z-220330T1800Z/ </value> </cap:parameter> <cap:parameter> <valueName> eventEndingTime </valueName> <value> 2022-03-30T18:00:00+00:00 </value> </cap:parameter> </entry> </feed>
entries = soup.find_all('entry')
len(entries)
4
print(entries[0])
<entry> <id>https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.001.1</id> <link href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.001.1" rel="alternate"/> <updated>2022-03-30T09:37:00-04:00</updated> <published>2022-03-30T09:37:00-04:00</published> <author> <name>NWS</name> </author> <title>Winter Weather Advisory issued March 30 at 9:37AM EDT until March 30 at 1:00PM EDT by NWS Buffalo NY</title> <summary>* WHAT...Freezing rain. Additional ice accumulations of a few hundredths of an inch. * WHERE...Chautauqua, Cattaraugus, and Southern Erie counties. * WHEN...Until 1 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. The hazardous conditions could impact the morning commute.</summary> <cap:event>Winter Weather Advisory</cap:event> <cap:sent>2022-03-30T09:37:00-04:00</cap:sent> <cap:effective>2022-03-30T09:37:00-04:00</cap:effective> <cap:onset>2022-03-30T09:37:00-04:00</cap:onset> <cap:expires>2022-03-30T13:00:00-04:00</cap:expires> <cap:status>Actual</cap:status> <cap:msgType>Update</cap:msgType> <cap:category>Met</cap:category> <cap:urgency>Expected</cap:urgency> <cap:severity>Moderate</cap:severity> <cap:certainty>Likely</cap:certainty> <cap:areaDesc>Chautauqua; Cattaraugus; Southern Erie</cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName>SAME</valueName> <value>036013</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036009</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036029</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ019</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ020</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ085</value> </cap:geocode> <cap:parameter> <valueName>AWIPSidentifier</valueName> <value>WSWBUF</value> </cap:parameter> <cap:parameter> <valueName>WMOidentifier</valueName> <value>WWUS41 KBUF 301337</value> </cap:parameter> <cap:parameter> <valueName>NWSheadline</valueName> <value>WINTER WEATHER ADVISORY REMAINS IN EFFECT UNTIL 1 PM EDT THIS AFTERNOON</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>EAS</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>NWEM</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>CMAS</value> </cap:parameter> <cap:parameter> <valueName>VTEC</valueName> <value>/O.CON.KBUF.WW.Y.0021.000000T0000Z-220330T1700Z/</value> </cap:parameter> <cap:parameter> <valueName>eventEndingTime</valueName> <value>2022-03-30T17:00:00+00:00</value> </cap:parameter> <cap:parameter> <valueName>expiredReferences</valueName> <value>w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.fb417b8a5f3d3ca30a74ead13b89475cfd6b1e93.001.1,2022-03-29T21:58:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.5636dcaa2c8b053113bcfb1fb3a80eb99bc68cb2.001.1,2022-03-29T13:35:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.002.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.001.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.d6432c96f6101e9d1b6d5fb0e338856f727a922d.001.1,2021-11-19T09:23:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.001.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.002.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.002.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.001.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.001.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.002.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.001.1,2021-11-18T03:14:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.002.1,2021-11-18T03:14:00-05:00</value> </cap:parameter> </entry>
e = entries[0]
e
<entry> <id>https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.001.1</id> <link href="https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.be4e7d7013ab357bf4bbc5ce2e662c1bcdccc914.001.1" rel="alternate"/> <updated>2022-03-30T09:37:00-04:00</updated> <published>2022-03-30T09:37:00-04:00</published> <author> <name>NWS</name> </author> <title>Winter Weather Advisory issued March 30 at 9:37AM EDT until March 30 at 1:00PM EDT by NWS Buffalo NY</title> <summary>* WHAT...Freezing rain. Additional ice accumulations of a few hundredths of an inch. * WHERE...Chautauqua, Cattaraugus, and Southern Erie counties. * WHEN...Until 1 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. The hazardous conditions could impact the morning commute.</summary> <cap:event>Winter Weather Advisory</cap:event> <cap:sent>2022-03-30T09:37:00-04:00</cap:sent> <cap:effective>2022-03-30T09:37:00-04:00</cap:effective> <cap:onset>2022-03-30T09:37:00-04:00</cap:onset> <cap:expires>2022-03-30T13:00:00-04:00</cap:expires> <cap:status>Actual</cap:status> <cap:msgType>Update</cap:msgType> <cap:category>Met</cap:category> <cap:urgency>Expected</cap:urgency> <cap:severity>Moderate</cap:severity> <cap:certainty>Likely</cap:certainty> <cap:areaDesc>Chautauqua; Cattaraugus; Southern Erie</cap:areaDesc> <cap:polygon/> <cap:geocode> <valueName>SAME</valueName> <value>036013</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036009</value> </cap:geocode> <cap:geocode> <valueName>SAME</valueName> <value>036029</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ019</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ020</value> </cap:geocode> <cap:geocode> <valueName>UGC</valueName> <value>NYZ085</value> </cap:geocode> <cap:parameter> <valueName>AWIPSidentifier</valueName> <value>WSWBUF</value> </cap:parameter> <cap:parameter> <valueName>WMOidentifier</valueName> <value>WWUS41 KBUF 301337</value> </cap:parameter> <cap:parameter> <valueName>NWSheadline</valueName> <value>WINTER WEATHER ADVISORY REMAINS IN EFFECT UNTIL 1 PM EDT THIS AFTERNOON</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>EAS</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>NWEM</value> </cap:parameter> <cap:parameter> <valueName>BLOCKCHANNEL</valueName> <value>CMAS</value> </cap:parameter> <cap:parameter> <valueName>VTEC</valueName> <value>/O.CON.KBUF.WW.Y.0021.000000T0000Z-220330T1700Z/</value> </cap:parameter> <cap:parameter> <valueName>eventEndingTime</valueName> <value>2022-03-30T17:00:00+00:00</value> </cap:parameter> <cap:parameter> <valueName>expiredReferences</valueName> <value>w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.fb417b8a5f3d3ca30a74ead13b89475cfd6b1e93.001.1,2022-03-29T21:58:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.5636dcaa2c8b053113bcfb1fb3a80eb99bc68cb2.001.1,2022-03-29T13:35:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.002.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9bc00a6fdbf966b8f59ecabf630e28c6aebfea6d.001.1,2021-11-19T03:32:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.d6432c96f6101e9d1b6d5fb0e338856f727a922d.001.1,2021-11-19T09:23:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.001.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.a1fe84d46b429c4cfe607be32ec40590760bab33.002.1,2021-11-18T20:05:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.002.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.03435f06993f933e3d96622609743d653cd2f195.001.1,2021-11-18T14:45:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.001.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.98642c58dcd44194d0be6d5318b85906020adaf0.002.1,2021-11-18T09:33:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.001.1,2021-11-18T03:14:00-05:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.e6f5df5c3e02407acb61dab00e08f1f4e9a86908.002.1,2021-11-18T03:14:00-05:00</value> </cap:parameter> </entry>
e.find('title')
<title>Winter Weather Advisory issued March 30 at 9:37AM EDT until March 30 at 1:00PM EDT by NWS Buffalo NY</title>
e.find('summary')
<summary>* WHAT...Freezing rain. Additional ice accumulations of a few hundredths of an inch. * WHERE...Chautauqua, Cattaraugus, and Southern Erie counties. * WHEN...Until 1 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. The hazardous conditions could impact the morning commute.</summary>
e.find('cap:areaDesc')
<cap:areaDesc>Chautauqua; Cattaraugus; Southern Erie</cap:areaDesc>
for e in soup.find_all('entry'):
print(e.find('title').get_text())
print("Area: ", e.find('cap:areaDesc').get_text())
print(e.find('summary').get_text())
print('\n')
Winter Weather Advisory issued March 30 at 9:37AM EDT until March 30 at 1:00PM EDT by NWS Buffalo NY Area: Chautauqua; Cattaraugus; Southern Erie * WHAT...Freezing rain. Additional ice accumulations of a few hundredths of an inch. * WHERE...Chautauqua, Cattaraugus, and Southern Erie counties. * WHEN...Until 1 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. The hazardous conditions could impact the morning commute. Winter Weather Advisory issued March 30 at 9:37AM EDT until March 30 at 1:00PM EDT by NWS Buffalo NY Area: Wyoming; Livingston; Ontario; Allegany * WHAT...Freezing rain. Additional ice accumulations of a few hundredths of an inch. * WHERE...Wyoming, Livingston, Ontario, and Allegany counties. * WHEN...Until 1 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions. The hazardous conditions could impact the morning commute. Wind Advisory issued March 30 at 9:35AM EDT until March 31 at 10:00AM EDT by NWS Buffalo NY Area: Chautauqua; Southern Erie * WHAT...South winds 25 to 35 mph with gusts up to 50 mph expected. * WHERE...Chautauqua and Southern Erie counties. Strongest winds along the Lake Erie shore and north facing slopes. * WHEN...From 8 PM this evening to 10 AM EDT Thursday. * IMPACTS...Gusty winds could blow around unsecured objects. Tree limbs could be blown down and a few isolated power outages may result. Winter Weather Advisory issued March 30 at 3:51AM EDT until March 30 at 2:00PM EDT by NWS Binghamton NY Area: Yates; Steuben; Schuyler; Chemung; Bradford * WHAT...Mixed precipitation expected. Total snow accumulations of up to one inch and ice accumulations of a light glaze. * WHERE...In Pennsylvania, Bradford county. In New York, Chemung, Yates, Schuyler and Steuben counties. * WHEN...From 8 AM this morning to 2 PM EDT this afternoon. * IMPACTS...Plan on slippery road conditions.
lat = 42.8803
lon = -78.8787
point_url = f"https://api.weather.gov/points/{lat},{lon}"
point_url
'https://api.weather.gov/points/42.8803,-78.8787'
r = requests.get(point_url)
print(r.text)
{ "@context": [ "https://geojson.org/geojson-ld/geojson-context.jsonld", { "@version": "1.1", "wx": "https://api.weather.gov/ontology#", "s": "https://schema.org/", "geo": "http://www.opengis.net/ont/geosparql#", "unit": "http://codes.wmo.int/common/unit/", "@vocab": "https://api.weather.gov/ontology#", "geometry": { "@id": "s:GeoCoordinates", "@type": "geo:wktLiteral" }, "city": "s:addressLocality", "state": "s:addressRegion", "distance": { "@id": "s:Distance", "@type": "s:QuantitativeValue" }, "bearing": { "@type": "s:QuantitativeValue" }, "value": { "@id": "s:value" }, "unitCode": { "@id": "s:unitCode", "@type": "@id" }, "forecastOffice": { "@type": "@id" }, "forecastGridData": { "@type": "@id" }, "publicZone": { "@type": "@id" }, "county": { "@type": "@id" } } ], "id": "https://api.weather.gov/points/42.8803,-78.8787", "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -78.878699999999995, 42.880299999999998 ] }, "properties": { "@id": "https://api.weather.gov/points/42.8803,-78.8787", "@type": "wx:Point", "cwa": "BUF", "forecastOffice": "https://api.weather.gov/offices/BUF", "gridId": "BUF", "gridX": 35, "gridY": 46, "forecast": "https://api.weather.gov/gridpoints/BUF/35,46/forecast", "forecastHourly": "https://api.weather.gov/gridpoints/BUF/35,46/forecast/hourly", "forecastGridData": "https://api.weather.gov/gridpoints/BUF/35,46", "observationStations": "https://api.weather.gov/gridpoints/BUF/35,46/stations", "relativeLocation": { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -78.859685999999996, 42.892491999999997 ] }, "properties": { "city": "Buffalo", "state": "NY", "distance": { "unitCode": "wmoUnit:m", "value": 2058.5677414788001 }, "bearing": { "unitCode": "wmoUnit:degree_(angle)", "value": 228 } } }, "forecastZone": "https://api.weather.gov/zones/forecast/NYZ010", "county": "https://api.weather.gov/zones/county/NYC029", "fireWeatherZone": "https://api.weather.gov/zones/fire/NYZ010", "timeZone": "America/New_York", "radarStation": "KBUF" } }
data = r.json()
data
{'@context': ['https://geojson.org/geojson-ld/geojson-context.jsonld', {'@version': '1.1', 'wx': 'https://api.weather.gov/ontology#', 's': 'https://schema.org/', 'geo': 'http://www.opengis.net/ont/geosparql#', 'unit': 'http://codes.wmo.int/common/unit/', '@vocab': 'https://api.weather.gov/ontology#', 'geometry': {'@id': 's:GeoCoordinates', '@type': 'geo:wktLiteral'}, 'city': 's:addressLocality', 'state': 's:addressRegion', 'distance': {'@id': 's:Distance', '@type': 's:QuantitativeValue'}, 'bearing': {'@type': 's:QuantitativeValue'}, 'value': {'@id': 's:value'}, 'unitCode': {'@id': 's:unitCode', '@type': '@id'}, 'forecastOffice': {'@type': '@id'}, 'forecastGridData': {'@type': '@id'}, 'publicZone': {'@type': '@id'}, 'county': {'@type': '@id'}}], 'id': 'https://api.weather.gov/points/42.8803,-78.8787', 'type': 'Feature', 'geometry': {'type': 'Point', 'coordinates': [-78.8787, 42.8803]}, 'properties': {'@id': 'https://api.weather.gov/points/42.8803,-78.8787', '@type': 'wx:Point', 'cwa': 'BUF', 'forecastOffice': 'https://api.weather.gov/offices/BUF', 'gridId': 'BUF', 'gridX': 35, 'gridY': 46, 'forecast': 'https://api.weather.gov/gridpoints/BUF/35,46/forecast', 'forecastHourly': 'https://api.weather.gov/gridpoints/BUF/35,46/forecast/hourly', 'forecastGridData': 'https://api.weather.gov/gridpoints/BUF/35,46', 'observationStations': 'https://api.weather.gov/gridpoints/BUF/35,46/stations', 'relativeLocation': {'type': 'Feature', 'geometry': {'type': 'Point', 'coordinates': [-78.859686, 42.892492]}, 'properties': {'city': 'Buffalo', 'state': 'NY', 'distance': {'unitCode': 'wmoUnit:m', 'value': 2058.5677414788}, 'bearing': {'unitCode': 'wmoUnit:degree_(angle)', 'value': 228}}}, 'forecastZone': 'https://api.weather.gov/zones/forecast/NYZ010', 'county': 'https://api.weather.gov/zones/county/NYC029', 'fireWeatherZone': 'https://api.weather.gov/zones/fire/NYZ010', 'timeZone': 'America/New_York', 'radarStation': 'KBUF'}}
data.keys()
dict_keys(['@context', 'id', 'type', 'geometry', 'properties'])
data['@context']
['https://geojson.org/geojson-ld/geojson-context.jsonld', {'@version': '1.1', 'wx': 'https://api.weather.gov/ontology#', 's': 'https://schema.org/', 'geo': 'http://www.opengis.net/ont/geosparql#', 'unit': 'http://codes.wmo.int/common/unit/', '@vocab': 'https://api.weather.gov/ontology#', 'geometry': {'@id': 's:GeoCoordinates', '@type': 'geo:wktLiteral'}, 'city': 's:addressLocality', 'state': 's:addressRegion', 'distance': {'@id': 's:Distance', '@type': 's:QuantitativeValue'}, 'bearing': {'@type': 's:QuantitativeValue'}, 'value': {'@id': 's:value'}, 'unitCode': {'@id': 's:unitCode', '@type': '@id'}, 'forecastOffice': {'@type': '@id'}, 'forecastGridData': {'@type': '@id'}, 'publicZone': {'@type': '@id'}, 'county': {'@type': '@id'}}]
data['@context'][0]
'https://geojson.org/geojson-ld/geojson-context.jsonld'
data['properties']
{'@id': 'https://api.weather.gov/points/42.8803,-78.8787', '@type': 'wx:Point', 'cwa': 'BUF', 'forecastOffice': 'https://api.weather.gov/offices/BUF', 'gridId': 'BUF', 'gridX': 35, 'gridY': 46, 'forecast': 'https://api.weather.gov/gridpoints/BUF/35,46/forecast', 'forecastHourly': 'https://api.weather.gov/gridpoints/BUF/35,46/forecast/hourly', 'forecastGridData': 'https://api.weather.gov/gridpoints/BUF/35,46', 'observationStations': 'https://api.weather.gov/gridpoints/BUF/35,46/stations', 'relativeLocation': {'type': 'Feature', 'geometry': {'type': 'Point', 'coordinates': [-78.859686, 42.892492]}, 'properties': {'city': 'Buffalo', 'state': 'NY', 'distance': {'unitCode': 'wmoUnit:m', 'value': 2058.5677414788}, 'bearing': {'unitCode': 'wmoUnit:degree_(angle)', 'value': 228}}}, 'forecastZone': 'https://api.weather.gov/zones/forecast/NYZ010', 'county': 'https://api.weather.gov/zones/county/NYC029', 'fireWeatherZone': 'https://api.weather.gov/zones/fire/NYZ010', 'timeZone': 'America/New_York', 'radarStation': 'KBUF'}
forecast = data['properties']['forecast']
forecast
'https://api.weather.gov/gridpoints/BUF/35,46/forecast'
data.keys()
dict_keys(['@context', 'id', 'type', 'geometry', 'properties'])
r = requests.get(forecast)
print(r.text)
{ "@context": [ "https://geojson.org/geojson-ld/geojson-context.jsonld", { "@version": "1.1", "wx": "https://api.weather.gov/ontology#", "geo": "http://www.opengis.net/ont/geosparql#", "unit": "http://codes.wmo.int/common/unit/", "@vocab": "https://api.weather.gov/ontology#" } ], "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ -78.882886600000006, 42.898999699999997 ], [ -78.886394800000005, 42.877477799999994 ], [ -78.857021799999998, 42.874904999999991 ], [ -78.853507399999998, 42.896426599999991 ], [ -78.882886600000006, 42.898999699999997 ] ] ] }, "properties": { "updated": "2022-03-30T13:38:16+00:00", "units": "us", "forecastGenerator": "BaselineForecastGenerator", "generatedAt": "2022-03-30T16:45:57+00:00", "updateTime": "2022-03-30T13:38:16+00:00", "validTimes": "2022-03-30T07:00:00+00:00/P7DT18H", "elevation": { "unitCode": "wmoUnit:m", "value": 184.0992 }, "periods": [ { "number": 1, "name": "This Afternoon", "startTime": "2022-03-30T12:00:00-04:00", "endTime": "2022-03-30T18:00:00-04:00", "isDaytime": true, "temperature": 51, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "10 mph", "windDirection": "SE", "icon": "https://api.weather.gov/icons/land/day/rain,50?size=medium", "shortForecast": "Chance Light Rain", "detailedForecast": "A chance of rain before 3pm. Cloudy, with a high near 51. Southeast wind around 10 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible." }, { "number": 2, "name": "Tonight", "startTime": "2022-03-30T18:00:00-04:00", "endTime": "2022-03-31T06:00:00-04:00", "isDaytime": false, "temperature": 46, "temperatureUnit": "F", "temperatureTrend": "rising", "windSpeed": "8 to 20 mph", "windDirection": "SE", "icon": "https://api.weather.gov/icons/land/night/bkn/rain_showers,40?size=medium", "shortForecast": "Mostly Cloudy then Chance Rain Showers", "detailedForecast": "A chance of rain showers after 4am. Mostly cloudy. Low around 46, with temperatures rising to around 55 overnight. Southeast wind 8 to 20 mph, with gusts as high as 33 mph. Chance of precipitation is 40%. New rainfall amounts less than a tenth of an inch possible." }, { "number": 3, "name": "Thursday", "startTime": "2022-03-31T06:00:00-04:00", "endTime": "2022-03-31T18:00:00-04:00", "isDaytime": true, "temperature": 60, "temperatureUnit": "F", "temperatureTrend": "falling", "windSpeed": "20 to 23 mph", "windDirection": "SW", "icon": "https://api.weather.gov/icons/land/day/rain_showers,70/tsra_sct,60?size=medium", "shortForecast": "Rain Showers Likely", "detailedForecast": "Rain showers likely before 3pm, then showers and thunderstorms likely. Mostly cloudy. High near 60, with temperatures falling to around 49 in the afternoon. Southwest wind 20 to 23 mph, with gusts as high as 41 mph. Chance of precipitation is 70%. New rainfall amounts less than a tenth of an inch possible." }, { "number": 4, "name": "Thursday Night", "startTime": "2022-03-31T18:00:00-04:00", "endTime": "2022-04-01T06:00:00-04:00", "isDaytime": false, "temperature": 34, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "14 to 22 mph", "windDirection": "SW", "icon": "https://api.weather.gov/icons/land/night/rain_showers,50/snow,50?size=medium", "shortForecast": "Chance Rain Showers then Chance Rain And Snow Showers", "detailedForecast": "A chance of rain showers before 2am, then a chance of rain and snow showers. Mostly cloudy, with a low around 34. Southwest wind 14 to 22 mph, with gusts as high as 36 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible." }, { "number": 5, "name": "Friday", "startTime": "2022-04-01T06:00:00-04:00", "endTime": "2022-04-01T18:00:00-04:00", "isDaytime": true, "temperature": 38, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "13 to 17 mph", "windDirection": "W", "icon": "https://api.weather.gov/icons/land/day/snow,50?size=medium", "shortForecast": "Chance Snow Showers", "detailedForecast": "A chance of snow showers before 10am, then a chance of rain and snow showers. Mostly cloudy, with a high near 38. West wind 13 to 17 mph, with gusts as high as 30 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible." }, { "number": 6, "name": "Friday Night", "startTime": "2022-04-01T18:00:00-04:00", "endTime": "2022-04-02T06:00:00-04:00", "isDaytime": false, "temperature": 28, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "7 to 17 mph", "windDirection": "W", "icon": "https://api.weather.gov/icons/land/night/snow,20/sct?size=medium", "shortForecast": "Slight Chance Rain And Snow Showers then Partly Cloudy", "detailedForecast": "A slight chance of rain and snow showers before 8pm. Partly cloudy, with a low around 28. Chance of precipitation is 20%." }, { "number": 7, "name": "Saturday", "startTime": "2022-04-02T06:00:00-04:00", "endTime": "2022-04-02T18:00:00-04:00", "isDaytime": true, "temperature": 45, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "9 mph", "windDirection": "SW", "icon": "https://api.weather.gov/icons/land/day/sct?size=medium", "shortForecast": "Mostly Sunny", "detailedForecast": "Mostly sunny, with a high near 45." }, { "number": 8, "name": "Saturday Night", "startTime": "2022-04-02T18:00:00-04:00", "endTime": "2022-04-03T06:00:00-04:00", "isDaytime": false, "temperature": 32, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "2 to 7 mph", "windDirection": "SW", "icon": "https://api.weather.gov/icons/land/night/bkn/snow?size=medium", "shortForecast": "Mostly Cloudy then Slight Chance Rain And Snow Showers", "detailedForecast": "A slight chance of rain and snow showers after 2am. Mostly cloudy, with a low around 32." }, { "number": 9, "name": "Sunday", "startTime": "2022-04-03T06:00:00-04:00", "endTime": "2022-04-03T18:00:00-04:00", "isDaytime": true, "temperature": 45, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "3 to 8 mph", "windDirection": "W", "icon": "https://api.weather.gov/icons/land/day/snow/bkn?size=medium", "shortForecast": "Slight Chance Snow Showers then Mostly Cloudy", "detailedForecast": "A slight chance of snow showers before 7am, then a slight chance of rain and snow showers between 7am and 8am. Mostly cloudy, with a high near 45." }, { "number": 10, "name": "Sunday Night", "startTime": "2022-04-03T18:00:00-04:00", "endTime": "2022-04-04T06:00:00-04:00", "isDaytime": false, "temperature": 32, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "7 mph", "windDirection": "W", "icon": "https://api.weather.gov/icons/land/night/bkn?size=medium", "shortForecast": "Mostly Cloudy", "detailedForecast": "Mostly cloudy, with a low around 32." }, { "number": 11, "name": "Monday", "startTime": "2022-04-04T06:00:00-04:00", "endTime": "2022-04-04T18:00:00-04:00", "isDaytime": true, "temperature": 48, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "5 to 8 mph", "windDirection": "W", "icon": "https://api.weather.gov/icons/land/day/bkn/rain_showers?size=medium", "shortForecast": "Partly Sunny then Slight Chance Rain Showers", "detailedForecast": "A slight chance of rain showers after 2pm. Partly sunny, with a high near 48." }, { "number": 12, "name": "Monday Night", "startTime": "2022-04-04T18:00:00-04:00", "endTime": "2022-04-05T06:00:00-04:00", "isDaytime": false, "temperature": 34, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "3 to 7 mph", "windDirection": "S", "icon": "https://api.weather.gov/icons/land/night/rain_showers/bkn?size=medium", "shortForecast": "Slight Chance Rain Showers then Mostly Cloudy", "detailedForecast": "A slight chance of rain showers before 8pm. Mostly cloudy, with a low around 34." }, { "number": 13, "name": "Tuesday", "startTime": "2022-04-05T06:00:00-04:00", "endTime": "2022-04-05T18:00:00-04:00", "isDaytime": true, "temperature": 53, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "6 mph", "windDirection": "SE", "icon": "https://api.weather.gov/icons/land/day/bkn/rain_showers?size=medium", "shortForecast": "Partly Sunny then Slight Chance Rain Showers", "detailedForecast": "A slight chance of rain showers after 2pm. Partly sunny, with a high near 53." }, { "number": 14, "name": "Tuesday Night", "startTime": "2022-04-05T18:00:00-04:00", "endTime": "2022-04-06T06:00:00-04:00", "isDaytime": false, "temperature": 40, "temperatureUnit": "F", "temperatureTrend": null, "windSpeed": "6 to 9 mph", "windDirection": "E", "icon": "https://api.weather.gov/icons/land/night/rain_showers,40?size=medium", "shortForecast": "Chance Rain Showers", "detailedForecast": "A chance of rain showers. Mostly cloudy, with a low around 40. Chance of precipitation is 40%." } ] } }
f = r.json()
f['@context']
['https://geojson.org/geojson-ld/geojson-context.jsonld', {'@version': '1.1', 'wx': 'https://api.weather.gov/ontology#', 'geo': 'http://www.opengis.net/ont/geosparql#', 'unit': 'http://codes.wmo.int/common/unit/', '@vocab': 'https://api.weather.gov/ontology#'}]
f.keys()
dict_keys(['@context', 'type', 'geometry', 'properties'])
f['properties']['periods']
[{'number': 1, 'name': 'This Afternoon', 'startTime': '2022-03-30T12:00:00-04:00', 'endTime': '2022-03-30T18:00:00-04:00', 'isDaytime': True, 'temperature': 51, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '10 mph', 'windDirection': 'SE', 'icon': 'https://api.weather.gov/icons/land/day/rain,50?size=medium', 'shortForecast': 'Chance Light Rain', 'detailedForecast': 'A chance of rain before 3pm. Cloudy, with a high near 51. Southeast wind around 10 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible.'}, {'number': 2, 'name': 'Tonight', 'startTime': '2022-03-30T18:00:00-04:00', 'endTime': '2022-03-31T06:00:00-04:00', 'isDaytime': False, 'temperature': 46, 'temperatureUnit': 'F', 'temperatureTrend': 'rising', 'windSpeed': '8 to 20 mph', 'windDirection': 'SE', 'icon': 'https://api.weather.gov/icons/land/night/bkn/rain_showers,40?size=medium', 'shortForecast': 'Mostly Cloudy then Chance Rain Showers', 'detailedForecast': 'A chance of rain showers after 4am. Mostly cloudy. Low around 46, with temperatures rising to around 55 overnight. Southeast wind 8 to 20 mph, with gusts as high as 33 mph. Chance of precipitation is 40%. New rainfall amounts less than a tenth of an inch possible.'}, {'number': 3, 'name': 'Thursday', 'startTime': '2022-03-31T06:00:00-04:00', 'endTime': '2022-03-31T18:00:00-04:00', 'isDaytime': True, 'temperature': 60, 'temperatureUnit': 'F', 'temperatureTrend': 'falling', 'windSpeed': '20 to 23 mph', 'windDirection': 'SW', 'icon': 'https://api.weather.gov/icons/land/day/rain_showers,70/tsra_sct,60?size=medium', 'shortForecast': 'Rain Showers Likely', 'detailedForecast': 'Rain showers likely before 3pm, then showers and thunderstorms likely. Mostly cloudy. High near 60, with temperatures falling to around 49 in the afternoon. Southwest wind 20 to 23 mph, with gusts as high as 41 mph. Chance of precipitation is 70%. New rainfall amounts less than a tenth of an inch possible.'}, {'number': 4, 'name': 'Thursday Night', 'startTime': '2022-03-31T18:00:00-04:00', 'endTime': '2022-04-01T06:00:00-04:00', 'isDaytime': False, 'temperature': 34, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '14 to 22 mph', 'windDirection': 'SW', 'icon': 'https://api.weather.gov/icons/land/night/rain_showers,50/snow,50?size=medium', 'shortForecast': 'Chance Rain Showers then Chance Rain And Snow Showers', 'detailedForecast': 'A chance of rain showers before 2am, then a chance of rain and snow showers. Mostly cloudy, with a low around 34. Southwest wind 14 to 22 mph, with gusts as high as 36 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible.'}, {'number': 5, 'name': 'Friday', 'startTime': '2022-04-01T06:00:00-04:00', 'endTime': '2022-04-01T18:00:00-04:00', 'isDaytime': True, 'temperature': 38, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '13 to 17 mph', 'windDirection': 'W', 'icon': 'https://api.weather.gov/icons/land/day/snow,50?size=medium', 'shortForecast': 'Chance Snow Showers', 'detailedForecast': 'A chance of snow showers before 10am, then a chance of rain and snow showers. Mostly cloudy, with a high near 38. West wind 13 to 17 mph, with gusts as high as 30 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible.'}, {'number': 6, 'name': 'Friday Night', 'startTime': '2022-04-01T18:00:00-04:00', 'endTime': '2022-04-02T06:00:00-04:00', 'isDaytime': False, 'temperature': 28, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '7 to 17 mph', 'windDirection': 'W', 'icon': 'https://api.weather.gov/icons/land/night/snow,20/sct?size=medium', 'shortForecast': 'Slight Chance Rain And Snow Showers then Partly Cloudy', 'detailedForecast': 'A slight chance of rain and snow showers before 8pm. Partly cloudy, with a low around 28. Chance of precipitation is 20%.'}, {'number': 7, 'name': 'Saturday', 'startTime': '2022-04-02T06:00:00-04:00', 'endTime': '2022-04-02T18:00:00-04:00', 'isDaytime': True, 'temperature': 45, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '9 mph', 'windDirection': 'SW', 'icon': 'https://api.weather.gov/icons/land/day/sct?size=medium', 'shortForecast': 'Mostly Sunny', 'detailedForecast': 'Mostly sunny, with a high near 45.'}, {'number': 8, 'name': 'Saturday Night', 'startTime': '2022-04-02T18:00:00-04:00', 'endTime': '2022-04-03T06:00:00-04:00', 'isDaytime': False, 'temperature': 32, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '2 to 7 mph', 'windDirection': 'SW', 'icon': 'https://api.weather.gov/icons/land/night/bkn/snow?size=medium', 'shortForecast': 'Mostly Cloudy then Slight Chance Rain And Snow Showers', 'detailedForecast': 'A slight chance of rain and snow showers after 2am. Mostly cloudy, with a low around 32.'}, {'number': 9, 'name': 'Sunday', 'startTime': '2022-04-03T06:00:00-04:00', 'endTime': '2022-04-03T18:00:00-04:00', 'isDaytime': True, 'temperature': 45, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '3 to 8 mph', 'windDirection': 'W', 'icon': 'https://api.weather.gov/icons/land/day/snow/bkn?size=medium', 'shortForecast': 'Slight Chance Snow Showers then Mostly Cloudy', 'detailedForecast': 'A slight chance of snow showers before 7am, then a slight chance of rain and snow showers between 7am and 8am. Mostly cloudy, with a high near 45.'}, {'number': 10, 'name': 'Sunday Night', 'startTime': '2022-04-03T18:00:00-04:00', 'endTime': '2022-04-04T06:00:00-04:00', 'isDaytime': False, 'temperature': 32, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '7 mph', 'windDirection': 'W', 'icon': 'https://api.weather.gov/icons/land/night/bkn?size=medium', 'shortForecast': 'Mostly Cloudy', 'detailedForecast': 'Mostly cloudy, with a low around 32.'}, {'number': 11, 'name': 'Monday', 'startTime': '2022-04-04T06:00:00-04:00', 'endTime': '2022-04-04T18:00:00-04:00', 'isDaytime': True, 'temperature': 48, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '5 to 8 mph', 'windDirection': 'W', 'icon': 'https://api.weather.gov/icons/land/day/bkn/rain_showers?size=medium', 'shortForecast': 'Partly Sunny then Slight Chance Rain Showers', 'detailedForecast': 'A slight chance of rain showers after 2pm. Partly sunny, with a high near 48.'}, {'number': 12, 'name': 'Monday Night', 'startTime': '2022-04-04T18:00:00-04:00', 'endTime': '2022-04-05T06:00:00-04:00', 'isDaytime': False, 'temperature': 34, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '3 to 7 mph', 'windDirection': 'S', 'icon': 'https://api.weather.gov/icons/land/night/rain_showers/bkn?size=medium', 'shortForecast': 'Slight Chance Rain Showers then Mostly Cloudy', 'detailedForecast': 'A slight chance of rain showers before 8pm. Mostly cloudy, with a low around 34.'}, {'number': 13, 'name': 'Tuesday', 'startTime': '2022-04-05T06:00:00-04:00', 'endTime': '2022-04-05T18:00:00-04:00', 'isDaytime': True, 'temperature': 53, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '6 mph', 'windDirection': 'SE', 'icon': 'https://api.weather.gov/icons/land/day/bkn/rain_showers?size=medium', 'shortForecast': 'Partly Sunny then Slight Chance Rain Showers', 'detailedForecast': 'A slight chance of rain showers after 2pm. Partly sunny, with a high near 53.'}, {'number': 14, 'name': 'Tuesday Night', 'startTime': '2022-04-05T18:00:00-04:00', 'endTime': '2022-04-06T06:00:00-04:00', 'isDaytime': False, 'temperature': 40, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '6 to 9 mph', 'windDirection': 'E', 'icon': 'https://api.weather.gov/icons/land/night/rain_showers,40?size=medium', 'shortForecast': 'Chance Rain Showers', 'detailedForecast': 'A chance of rain showers. Mostly cloudy, with a low around 40. Chance of precipitation is 40%.'}]
p = f['properties']['periods'][0]
p
{'number': 1, 'name': 'This Afternoon', 'startTime': '2022-03-30T12:00:00-04:00', 'endTime': '2022-03-30T18:00:00-04:00', 'isDaytime': True, 'temperature': 51, 'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '10 mph', 'windDirection': 'SE', 'icon': 'https://api.weather.gov/icons/land/day/rain,50?size=medium', 'shortForecast': 'Chance Light Rain', 'detailedForecast': 'A chance of rain before 3pm. Cloudy, with a high near 51. Southeast wind around 10 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible.'}
p['temperature']
51
p['temperatureUnit']
'F'
p['detailedForecast']
'A chance of rain before 3pm. Cloudy, with a high near 51. Southeast wind around 10 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible.'
nominatim_url = "https://nominatim.openstreetmap.org/search"
params = {"city": "Buffalo",
"state": "NY",
"format": "json"
}
r = requests.get(nominatim_url, params=params)
print(r.text)
[{"place_id":282417634,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"relation","osm_id":175031,"boundingbox":["42.8260387","42.9664686","-78.9194528","-78.7951677"],"lat":"42.8867166","lon":"-78.8783922","display_name":"Buffalo, Erie County, New York, United States","class":"boundary","type":"administrative","importance":0.7329312091953605,"icon":"https://nominatim.openstreetmap.org/ui/mapicons//poi_boundary_administrative.p.20.png"},{"place_id":411550,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":158576897,"boundingbox":["42.9183918","42.9583918","-78.7047515","-78.6647515"],"lat":"42.9383918","lon":"-78.6847515","display_name":"Bowmansville, Town of Lancaster, Erie County, New York, 14026, United States","class":"place","type":"hamlet","importance":0.25,"icon":"https://nominatim.openstreetmap.org/ui/mapicons//poi_place_village.p.20.png"}]
r.json()
[{'place_id': 282417634, 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright', 'osm_type': 'relation', 'osm_id': 175031, 'boundingbox': ['42.8260387', '42.9664686', '-78.9194528', '-78.7951677'], 'lat': '42.8867166', 'lon': '-78.8783922', 'display_name': 'Buffalo, Erie County, New York, United States', 'class': 'boundary', 'type': 'administrative', 'importance': 0.7329312091953605, 'icon': 'https://nominatim.openstreetmap.org/ui/mapicons//poi_boundary_administrative.p.20.png'}, {'place_id': 411550, 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright', 'osm_type': 'node', 'osm_id': 158576897, 'boundingbox': ['42.9183918', '42.9583918', '-78.7047515', '-78.6647515'], 'lat': '42.9383918', 'lon': '-78.6847515', 'display_name': 'Bowmansville, Town of Lancaster, Erie County, New York, 14026, United States', 'class': 'place', 'type': 'hamlet', 'importance': 0.25, 'icon': 'https://nominatim.openstreetmap.org/ui/mapicons//poi_place_village.p.20.png'}]
r.json()[0]['lat']
'42.8867166'
r.json()[0]['lon']
'-78.8783922'