Skip to content

Instantly share code, notes, and snippets.

@muhammedbasilsk
Forked from jineshpaloor/read_meta_data.py
Last active September 18, 2024 09:42
Show Gist options
  • Save muhammedbasilsk/36912695823a01a90eb1cac617f068ed to your computer and use it in GitHub Desktop.
Save muhammedbasilsk/36912695823a01a90eb1cac617f068ed to your computer and use it in GitHub Desktop.
Python program to read a url and extract its meta tags - Updated to latest package.
# pip install beautifulsoup4
# pip install requests
from bs4 import BeautifulSoup
import requests
def extract_meta(url):
r = requests.get(url)
print(dir(r))
soup = BeautifulSoup(r.text)
meta = soup.findAll('meta')
print(meta)
for tag in meta:
print(tag)
if __name__ == '__main__':
_url = 'http://www.sourcebits.com/'
extract_meta(_url)
@akashriyer9
Copy link

very helpful thank you

@ZaripovST
Copy link

не работает!!

@muhammedbasilsk
Copy link
Author

muhammedbasilsk commented Sep 18, 2024

@ZaripovST, the package was outdated. I fixed it now.
Please check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment