Monday, April 28, 2025

Extract Links from Webpage - Python - BeautifulSoup

This Python script will extract all links from single web page.

Make sure that you have Beautiful Soup module installed.

When you run script, it will ask you for target domain. After that request will be fired. Beautiful Soup is used to extract links with html.parser feature.

For loop is needed to list all links using find_all() method.

import requests
from bs4 import BeautifulSoup

host = input("Page to Check: ")

req = requests.get("http://" + host)
data = req.text

real_stuff = BeautifulSoup(data, features = 'html.parser')

for x in real_stuff.find_all('a'):
    print(x.get('href'))

Learn More:

Free Python Programming Course
Python Examples
Python How To
Python Modules 

YouTube WebDevPro Tutorials

No comments:

Post a Comment

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...