-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very helpful thank you