Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: Mario Lopes
Added: Nov 18, 2018 5:23 PM
Views: 28
  1. from bs4 import BeautifulSoup
  2. import requests
  3. url = "http://sapo.pt"
  4. url_get = requests.get(url)
  5. soup = BeautifulSoup(url_get.content, 'lxml')
  6. descricao = soup.find('meta', attrs={'name':'og:description'}) or soup.find('meta', attrs={'property':'description'}) or soup.find('meta', attrs={'name':'description'})    
  7. print (descricao)
  8.