I need help. I am very illiterate in Python and the like and I have a chunk of code that checks to see if a page updates and then posts it onto a forum. I need to alter it (hopefully) to check to see if an RRS feed is updated and post it in a different format.

So what I need help with is to change it to check to see if an RRS feed is running. Log in to https://store.steampowered.com/login/ and once it logs in access a groups announcement page so lets say this url http://steamcommunity.com/groups/vancouvercanucksregistered/announcements, when you are logged in and an admin it shows two spaces a "Headline" and a "Subject" space, it also has a post button.

P.S if you are interested because this shouldn't be too much coding, cooperation with me can happen over IM or other medians.

import sys
import re
import urllib2, cookielib

def u(s):
	if type(s) is type(u''):
		return s
	if type(s) is type(''):
			return unicode(s)
				return unicode(s.decode('utf8'))
					return unicode(s.decode('windows-1252'))
					return unicode(s, errors='ignore')
		return unicode(s)
			return u(str(s))
			return s
class SteamForumPoster:
	rootUrl = 'http://forums.steampowered.com/forums/'
	loginUrl = 'http://forums.steampowered.com/forums/login.php?do=login'
	postUrl = 'http://forums.steampowered.com/forums/newthread.php?do=newthread&f=%forumid%'
	extractFormToken = r'<input[^<>]*name="%token%"[^<>]*value="([^"]+)"'
	userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1'
	compiled = {}
	def __init__(self, username, password):
		self.username = u(username)
		self.password = u(password)
		self.loggedIn = False
		self.cookieJar = cookielib.CookieJar()
		self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar))
		self.lastReferrer = None
	def encodeParams(self, params):
		s = []
		for k in params:
			s.append(urllib2.quote(u(k)) + '=' + urllib2.quote(u(params[k])))
		return '&'.join(s)
	def regex(self, exp, flags=re.IGNORECASE):
		exp = u(exp)
		if exp not in SteamForumPoster.compiled:
			SteamForumPoster.compiled[exp] = re.compile(exp, flags)
		return self.compiled[exp]
	def getToken(self, content, token):
		res = self.regex(SteamForumPoster.extractFormToken.replace('%token%', re.escape(u(token)))).search(u(content))
		if res is None:
			return u''
		return u(res.group(1))
	def fetch(self, url, params=None, headers={}):
		if params is not None and type(params) is type({}):
			params = self.encodeParams(params)
		if params is not None:
			params = u(params).encode('utf8')
		if self.lastReferrer is not None:
			headers['Referer'] = self.lastReferrer
		headers['User-Agent'] = SteamForumPoster.userAgent
		self.lastReferrer = url
			return u(self.opener.open(urllib2.Request(url, data=params, headers=headers)).read(-1))
			return u''
	def login(self):
		homepageContent = self.fetch(SteamForumPoster.rootUrl)
		loginParams = {
			'vb_login_username': self.username,
			'cookieuse': 1,
			'vb_login_password': self.password,
			's': self.getToken(homepageContent, 's'),
			'securitytoken': self.getToken(homepageContent, 'securitytoken'),
			'do': 'login',
			'vb_login_md5password': '',
			'vb_login_md5password_utf': ''
		return self.fetch(SteamForumPoster.loginUrl, loginParams).find('Thank you for logging in') != -1
	def postThread(self, forumID, title, message, iconID=0):
		forumID = u(forumID)
		postPageContent = self.fetch(SteamForumPoster.postUrl.replace('%forumid%', forumID))
		postParams = {
			'subject': title,
			'message': message,
			'wysiwyg': 0,
			'iconid': iconID,
			'securitytoken': self.getToken(postPageContent, 'securitytoken'),
			's': self.getToken(postPageContent, 's'),
			'f': forumID,
			'do': 'postthread',
			'posthash': '',
			'poststarttime': '',
			'loggedinuser': self.getToken(postPageContent, 'loggedinuser'),
			'sbutton': 'Submit New Thread',
			'parseurl': 1,
			'emailupdate': 1
		return self.fetch(SteamForumPoster.postUrl.replace('%forumid%', forumID), postParams)
5 Years
Discussion Span
Last Post by meter1060
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.