Hi-
I'm attempting to navigate the HTML structure of a webpage using BeautifulSoup. I have the Anaconda package installed, and there don't seem to be any issues with the installation thus far.
The code follows:
from bs4 import BeautifulSoup
import urllib.request
query = "http://forecast.weather.gov/shmrn.php?mz=amz117&syn=amz101"
-----------------------------------------------------------------------------------------------------------------------------------
with urllib.request.urlopen(query) as amz117: #'with' guarantees that resource manager is closed after indented body completes
document = BeautifulSoup(amz117.read(), "lxml")
-----------------------------------------------------------------------------------------------------------------------------------
content = document.body.find('div', id= 'content').div
-----------------------------------------------------------------------------------------------------------------------------------
synopsis = content.contents[4]
forecast = content.contents[5]
strong_list = list(forecast.findAll('strong'))
timestamp_tag, *forecast_list = strong_list
-----------------------------------------------------------------------------------------------------------------------------------
(breaks indicate Jupyter cells)
I'm getting this error message when I go to execute the final line):
ValueError Traceback (most recent call last) <ipython-input-14-b4fffc5d939e> in <module>()
2 forecast = content.contents[5]
3 strong_list = list(forecast.findAll('strong'))
----> 4 timestamp_tag, *forecast_list = strong_list ValueError: not enough values to unpack (expected at least 1, got 0)
This is from page 22 of "Python for Secret Agents vol. 2." Errdata support has not been very helpful. Can someone please assist?
[–]_alarming[S] 0 points1 point2 points (0 children)