23 lines
818 B
Python
23 lines
818 B
Python
import feedparser
|
|
import io
|
|
import html
|
|
import datetime
|
|
import requests
|
|
import time
|
|
|
|
url = r'https://www.xboxygen.com/spip.php?page=backend'
|
|
|
|
html_text = requests.get(url).text
|
|
news = feedparser.parse(html_text)
|
|
|
|
yesterday_6am = datetime.datetime.now(datetime.timezone.utc).replace(hour=6, minute=0, second=0, microsecond=0) - datetime.timedelta(days=1)
|
|
|
|
try:
|
|
new_posts = [entry for entry in news.entries if datetime.datetime.strptime(entry.published.replace('GMT', '+0000'), '%a, %d %b %Y %H:%M:%S %z') > yesterday_6am]
|
|
|
|
except:
|
|
new_posts = [entry for entry in news.entries if datetime.datetime.fromtimestamp(time.mktime(entry.updated_parsed)).replace(tzinfo=datetime.timezone.utc) > yesterday_6am]
|
|
#else if
|
|
#entry.updated.replace('GMT', '+0000'), '%a, %d %b %Y %H:%M:%S %z'
|
|
|
|
print(new_posts) |