Skip to content

Instantly share code, notes, and snippets.

@krmaxwell
Created September 20, 2012 15:25
Show Gist options
  • Save krmaxwell/3756577 to your computer and use it in GitHub Desktop.
Save krmaxwell/3756577 to your computer and use it in GitHub Desktop.
Meta tags and BeautifulSoup
from bs4 import BeautifulSoup
soup = BeautifulSoup(response)
metatags = soup.find_all('meta',attrs={'name':'generator'})
for tag in metatags:
print tag
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<meta content="WordPress 3.4.2" name="generator"/>
@nihanyatir
Copy link

You saved my life!

@Ixod3
Copy link

Ixod3 commented Dec 31, 2022

Thanks for your solution :)

@swfh
Copy link

swfh commented Sep 28, 2023

I am trying to find a way of parsing the meta tags into either an array or JSON as name value pairs - i.e [{'name':'title','content':'my title'},{'name':'url','content':'https//www.url.com'}]?

@Mkurbanov
Copy link

thanks

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