{"id":30315732,"url":"https://github.com/ledangquangdangquang/blocktheweb","last_synced_at":"2026-06-26T09:31:28.998Z","repository":{"id":265864108,"uuid":"896763416","full_name":"ledangquangdangquang/BlockTheWeb","owner":"ledangquangdangquang","description":"Block domain you don't want !!!","archived":false,"fork":false,"pushed_at":"2026-04-21T17:26:41.000Z","size":11844,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-21T19:36:17.161Z","etag":null,"topics":["blocklist","web","website-blocker"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ledangquangdangquang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-01T08:38:05.000Z","updated_at":"2026-04-21T17:26:44.000Z","dependencies_parsed_at":"2025-03-06T12:19:43.616Z","dependency_job_id":"a3ce6066-3bd6-444f-b66a-22746f2ac7cb","html_url":"https://github.com/ledangquangdangquang/BlockTheWeb","commit_stats":null,"previous_names":["quanghusst/blocktheweb","ledangquangdangquang/blocktheweb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ledangquangdangquang/BlockTheWeb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledangquangdangquang%2FBlockTheWeb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledangquangdangquang%2FBlockTheWeb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledangquangdangquang%2FBlockTheWeb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledangquangdangquang%2FBlockTheWeb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ledangquangdangquang","download_url":"https://codeload.github.com/ledangquangdangquang/BlockTheWeb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledangquangdangquang%2FBlockTheWeb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34811914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-26T02:00:06.560Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blocklist","web","website-blocker"],"created_at":"2025-08-17T19:50:18.081Z","updated_at":"2026-06-26T09:31:28.965Z","avatar_url":"https://github.com/ledangquangdangquang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Block Websites Based on Google Search Results\n\nThis Python script automates the process of blocking websites based on Google search results by modifying the system's `hosts` file. It uses the SerpAPI to fetch search results, extracts domain names from the URLs, and then appends these domains to the `hosts` file, effectively blocking them.\n\n## Prerequisites\n\n-   Python 3.x\n-   `serpapi` library: Install using `pip install google-search-results`\n-   SerpAPI API key: You need a SerpAPI account and API key to use this script. Replace `\"d7b14c71aee0bade7ac6c0358c845315c94d27ab53539ea7d39ee1a2d8cf2468\"` with your own API key.\n-   Administrative privileges: The script modifies the `hosts` file, which requires administrative rights.\n\n## How to Use\n\n1.  **Install Dependencies:**\n    ```bash    \n    pip install -r requirements.txt\n    ```\n2.  **Replace API Key:**\n    -   Open the Python script (`main.py`).\n    -   Locate the `api_key` variable in the `get_domains_from_serpapi` function.\n    -   Replace the placeholder value with your SerpAPI API key.\n3.  **Run the Script:**\n    -   Open a command prompt or terminal with administrative privileges.\n    -   Navigate to the directory containing the script.\n    -   Execute the script using `python main.py`.\n4.  **Enter Search Queries:**\n    -   The script will prompt you to enter a search query.\n    -   Enter your search query and press Enter.\n    -   The script will display the extracted domains and append them to the `hosts` file.\n    -   The script will print a confirmation message.\n    -   Press Enter to continue or Ctrl+C to exit.\n\n## Script Functionality\n  \n-   **`get_domains_from_serpapi(query, location, hl, gl, google_domain, api_key)`:**\n    - Takes a search query and optional parameters (location, language, etc.).\n    - Uses SerpAPI to perform a Google search.\n    - Extracts domain names from the search result URLs.\n    - Returns a list of unique domain names.\n    \n-   **`is_admin()`:**\n    - Checks if the script is running with administrative privileges.\n    - Returns `True` if running as admin, `False` otherwise.\n-   **`run_as_admin()`:**\n    - Requests administrative privileges if the script is not already running as admin.\n    - Restarts the script with elevated privileges.\n-   **Main Loop:**\n    - Prompts the user for a search query.\n    - Calls `get_domains_from_serpapi` to get the domains.\n    - Prints the extracted domain names.\n    - Appends the domains to the `hosts` file (``). Handles `PermissionError` if the script does not have administrator right. Handles generic Exceptions. Clear the console after each search. ## Important Notes Modifying the `hosts` file can affect your system's network behavior. Use with caution.\n-   Ensure you have the necessary permissions to modify the `hosts` file.\n-   The script is designed for Windows systems. The `hosts` file path may vary on other operating systems.\n-   Always use a valid SerpAPI API key.\n-   Be aware of the ethical implications of blocking websites.\n-   This script requires admin rights to run, it will ask for admin rights when the script is run.\n\n## Disclaimer\n\nThis script is provided as-is, and the user assumes all responsibility for its use. The author is not responsible for any damage or issues caused by this script.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledangquangdangquang%2Fblocktheweb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fledangquangdangquang%2Fblocktheweb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledangquangdangquang%2Fblocktheweb/lists"}