Python Web Scraping: Get the number of security alerts issued by US-CERT in the current year
Python Web Scraping: Exercise-14 with Solution
Write a Python program to get the number of security alerts issued by US-CERT in the current year.
Source: https://www.us-cert.gov/ncas/alerts
Sample Solution:
Python Code:
#https://bit.ly/2lVhlLX
import requests
from lxml import html
url = 'https://www.us-cert.gov/ncas/alerts'
doc = html.fromstring(requests.get(url).text)
print("The number of security alerts issued by US-CERT in the current year:")
print(len(doc.cssselect('.item-list li')))
Sample Output:
The number of security alerts issued by US-CERT in the current year: 37
Flowchart:

Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to get the number of people visiting a U.S. government website right now.
Next: Write a Python program to get the number of Pinterest accounts maintained by U.S. State Department embassies and missions.
What is the difficulty level of this exercise?
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join