Skip to main content

Top 100 Visited Sites Web Scraper

Description

This Python script is a simple web scraper that fetches data from a Wikipedia's Top 100 Sites (https://en.wikipedia.org/wiki/List_of_most-visited_websites), specifically an HTML table, and converts it into a list of dictionaries. It also accesses each domain in the list and prints its response code.

I created this script to automate testing of Firewall, Content Filtering and NAT related services. It can be used to test if a domain is accessible or not. It can also be used to test if a domain is being redirected to another domain.

Using this script helps me debug whether a rule (code) is working as expected or not. For example, if I have a rule that blocks access to a domain, I can use this script to test if the domain is indeed blocked or not. At the same time, I can get useful Syslogs for each run.

Dependencies

  • Python 3.6 or higher
  • requests library
  • BeautifulSoup from bs4 library
  • urlparse from urllib.parse library

Functions

  • is_valid_url(url: str) -> bool: Checks if the URL is valid.
  • html_table_to_list(url: str, num_columns: int) -> list: Converts an HTML table into a list of dictionaries.
  • access_domains(top_100: list) -> None: Accesses each domain in a list and prints its response code.

Usage

  1. Install the required dependencies.
  2. Run the script with Python 3.6 or higher.
  3. The script will fetch data from the specified URL, convert the HTML table into a list of dictionaries, and print the response code for each domain.

Please note that the URL of the webpage containing the table and the number of columns in the table are parameters for the html_table_to_list function. The default number of columns is set to 5.

The access_domains function takes in a list of dictionaries representing a table of domains and prints their response codes.

Example

# Use the function
top_100_reference = "https://en.wikipedia.org/wiki/List_of_most-visited_websites"  # Replace with your URL
top_100_list = html_table_to_list(top_100_reference)
access_domains(top_100_list)

In this example, the script fetches data from a Wikipedia page that lists the most visited websites, converts the HTML table into a list of dictionaries, and prints the response code for each domain.

Disclaimer

Please use this script responsibly and ensure that you are allowed to scrape the websites you choose to scrape. Some websites may prohibit scraping in their terms of service. Always respect others' intellectual property rights.

Metadata

Release files for top_100 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for top_100 0.1.4
File Size Uploaded Provenance Actions
top_100-0.1.4.tar.gz 6.9 kB Without provenance Details for top_100-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for top_100 0.1.4
File Interpreter ABI Platform Actions
top_100-0.1.4-py3-none-any.whl Python 3 none any Details for top_100-0.1.4-py3-none-any.whl

Total release size: 15.1 kB

Release files / top_100-0.1.4.tar.gz

Download URL top_100-0.1.4.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e9bfdded63f2b3e9b476c7a9d010284ea3ff9be26589daac7ecde9c2c94c481d
BLAKE2b-256 checksum
How to use checksums
2878abbbf8a0295a43091cb9ea05010a94b2e3c1c0290a9f9e13b0e22840e6c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Darwin/23.2.0

Release files / top_100-0.1.4-py3-none-any.whl

Download URL top_100-0.1.4-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d70ac508716feb6d0c4df065b31f72570e78b54fed61315326b1023c789f2aeb
BLAKE2b-256 checksum
How to use checksums
a0f77f76a5b9ca51c4692fb74907091b376862f27090fe5b5564927875093fe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Darwin/23.2.0

Security for top_100 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page