How to make All Link from given Webpage from basic a walk through of the projects- Python Mini Project with code Tutorial , so stay tune for more exciting projects. This Script retrieves all link from a given webpage and saves them as txt.
- Required Modules
to install these prerequisites.
$ pip install -r requirements.txt
How to run the Script
$ python get_link.py
Code to make All Link from given Webpage
import requests as rq from bs4 import BeautifulSoup url = input("Enter Link: ") if ("https" or "http") in url: data = rq.get(url) else: data = rq.get("https://" + url) soup = BeautifulSoup(data.text, "html.parser") links =  for link in soup.find_all("a"): links.append(link.get("href")) # Writing the output to a file (myLinks.txt) instead of to stdout # You can change 'a' to 'w' to overwrite the file each time with open("myLinks.txt", 'a') as saved: print(links[:10], file=saved)
in this article we have shown the code to build All Link from given Webpage , Hope you enjoyed the process