Skip to content

Instantly share code, notes, and snippets.

@takeshixx takeshixx/csgoblog.py
Last active Dec 5, 2018

Embed
What would you like to do?
Poll CS:GO blog for new blog posts.
#!/usr/bin/env python3
import sys
import time
import requests
import smtplib
import email.message
from lxml import html
SMTP_HOST = 'localhost'
SMTP_PORT = 25
SMTP_FROM = 'lol@valve.com'
SMTP_TO = SMTP_FROM
def sendinfo(title, url):
mail = email.message.EmailMessage()
mail.set_content('New CS:GO Blogpost: ' + url)
mail['Subject'] = title
mail['From'] = SMTP_FROM
mail['To'] = SMTP_TO
smtp = smtplib.SMTP(SMTP_HOST, SMTP_PORT)
smtp.send_message(mail)
smtp.quit()
if __name__ == '__main__':
res = requests.get('http://blog.counter-strike.net/')
doc = html.fromstring(res.text)
for i, container in enumerate(doc.find_class('inner_post')):
post = container.getchildren()[0]
title = post.getchildren()[0].text_content()
url = post.getchildren()[0].get("href")
if i is 0 and title != 'Blue Skies':
print('[' + time.asctime() + '] NEW BLOGPOST RELEASED:', title)
sendinfo(title, url)
sys.exit(0)
print('[' + time.asctime() + '] Nothing changed, yet...')
sys.exit(1)
while true;do /tmp/csgoblog.py && break;sleep 600;done
*/10 * * * * /tmp/csgoblog.py | tee -a /tmp/csgoblog.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.