Skip to content

Instantly share code, notes, and snippets.

@Frenzycore
Created December 27, 2025 06:00
Show Gist options
  • Select an option

  • Save Frenzycore/2adae20018bcde1599b6c28841104990 to your computer and use it in GitHub Desktop.

Select an option

Save Frenzycore/2adae20018bcde1599b6c28841104990 to your computer and use it in GitHub Desktop.
Crawling a Website for URLs
import requests
from bs4 import BeautifulSoup
def crawl_website(url):
try:
response = requests.get(url)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
urls = [a['href'] for a in soup.find_all('a', href=True)]
for link in urls:
print(link)
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
crawl_website("https://example.com")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment