Skip to content

Instantly share code, notes, and snippets.

@borjauria
Last active February 2, 2022 15:26
Show Gist options
  • Save borjauria/b3c93c7cdb1689650d2caa8bb9f39413 to your computer and use it in GitHub Desktop.
Save borjauria/b3c93c7cdb1689650d2caa8bb9f39413 to your computer and use it in GitHub Desktop.
import re
import requests
from bs4 import BeautifulSoup
from datetime import datetime
def scrapeDatatau(url):
try:
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
title = soup.find_all("td", {"class": "title"})
title_val = [tit.get_text() for tit in title][1]
title_val = re.sub('\\n','', title_val)
TimeNow = datetime.now()
return {
'date': str(TimeNow),
'title': title_val,
}
except Exception as e: print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment