Question: BlockPy: #48.2) Dracula Appears Project Gutenberg has a large number of classic books available, including the complete text of Dracula. Access the URL using the

BlockPy: #48.2) Dracula Appears Project Gutenberg has a large number of classic books available, including the complete text of Dracula. Access the URL using the requests module and the get function in order to count the number of times that "Dracula" appears in the story. Note that you may use the built-in count method of strings. Make sure you use this URL exactly in your code: 'http://www.gutenberg.org/cache/epub/345/pg345.txt'

BlockPy: #48.3) Live Temperatures

Live web feeds are an exciting way to make your programs respond to the world around them. In this problem, you will print out the current temperature for Blacksburg, Virginia. This data is available from the US Geological Service's Weather Forecast data stream. The URL below (note that it is one line, with no spaces or new lines) gives you access to the current information about Blacksburg weather:

"http://forecast.weather.gov/MapClick.php?lat=37.2327&lon=-80.4284&unit=0&lg=english&FcstType=json"

Use this URL and the requests module to access the JSON data behind the URL. This JSON data is organized as a dictionary of dictionaries of lists. The current temperature can be found by accessing the "data" key, then the "temperature"key, and then retrieving the first element of the subsequent list. Print that first temperature value.

Repeatedly accessing a real-world website like Forecast.gov is a little rude, especially if we all do it at once. Therefore, for this problem, we have captured a snapshot of the temperature. If you want to try your code in Spyder or Thonny, however, you should be able to see the actual temperature!

Note: Do not use the json module; use the json method of the response object.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!