Nov-16-2022, 05:39 PM
Hello,
For some reason, the following Python script that runs every hour through cron stops after the first run in the loop after downloading the RSS feed:
0 * * * * /root/feed.py > /usr/share/nginx/mysite/feed.html
And here's the outputt:
<!doctype html>
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>
<body><h1>Acme.com RSS feed</h1><ul>
<li><a href='https://www.acme.com/2022/11/15/latest-article/'>Latest article - 15 Nov 2022</a></li>
Any idea what it could be? I see nothing in /var/log/messsages.
Thank you.
For some reason, the following Python script that runs every hour through cron stops after the first run in the loop after downloading the RSS feed:
#!/usr/bin/python3 from bs4 import BeautifulSoup import requests import datetime as dt from datetime import datetime URL="https://www.acme.com/feed/" resp = requests.get(URL) soup = BeautifulSoup(resp.text,'xml') print("<!doctype html>") print('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>') print('<body><h1>Acme.com RSS feed</h1><ul>') for item in soup("item"): #Thu, 10 Nov 2022 18:15:41 +0000 date_obj = dt.datetime.strptime(item.pubDate.string, "%a, %d %b %Y %H:%M:%S %z") pubDate = "{} {} {}".format(date_obj.day,date_obj.strftime("%b"),date_obj.year) link=item.link.string title=item.title.string print("<li><a href='{}'>{} - {}</a></li>".format(link,title,pubDate)) print("</ul>") now = datetime.now() date_time = now.strftime("%d/%m//%Y %H:%M") print("Last updated: ",date_time) print("</body></html>")Here's crontab:
0 * * * * /root/feed.py > /usr/share/nginx/mysite/feed.html
And here's the outputt:
<!doctype html>
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>
<body><h1>Acme.com RSS feed</h1><ul>
<li><a href='https://www.acme.com/2022/11/15/latest-article/'>Latest article - 15 Nov 2022</a></li>
Any idea what it could be? I see nothing in /var/log/messsages.
Thank you.