Goglides Dev 🌱

Goglides Dev 🌱 is a community of amazing users

Shaping the future of IT, one connection at a time.

Create account Log in
Balkrishna Pandey
Balkrishna Pandey

Posted on

Python Parser get all Hyperlink in a webpage

Simple python script to get all hyperlink for a URL,

Save following script in a file name called app.py

import requests
from bs4 import BeautifulSoup
response = requests.get("https://www.goglides.dev")
soup = BeautifulSoup(response.content, 'html.parser')
links = soup.find_all('a')
for link in links:
    href = link.get('href')
    print(href)
Enter fullscreen mode Exit fullscreen mode

Make sure to install all dependencies before you run this python code.

pip install requests beautifulsoup4 selenium
Enter fullscreen mode Exit fullscreen mode

Finally run the code as follows,

python app.py
Enter fullscreen mode Exit fullscreen mode

Output:

...
/contact
/code-of-conduct
/privacy
/terms
https://twitter.com/go_glides
https://facebook.com/goglides.dev
https://instagram.com/goglides
...
Enter fullscreen mode Exit fullscreen mode

Discussion (0)