Python Web Scraping: Get the number of datasets currently listed on data.gov
Python Web Scraping: Exercise-3 with Solution
Write a Python program to get the number of datasets currently listed on data.gov.
Sample Solution:
Python Code:
from lxml import html
import requests
response = requests.get('http://www.data.gov/')
doc_gov = html.fromstring(response.text)
link_gov = doc_gov.cssselect('small a')[0]
print("Number of datasets currently listed on data.gov:")
print(link_gov.text)
Sample Output:
Number of datasets currently listed on data.gov: 285,397 datasets
Flowchart:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to download and display the content of robot.txt for en.wikipedia.org.
Next: Write a Python program to convert an address into geographic coordinates.
What is the difficulty level of this exercise?
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/python-exercises/web-scraping/web-scraping-exercise-3.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics