Automatically Change Forum Signature
Go to solution
Solved by fizzlesticks,
For various reasons such as Cloudflare, login/session cookies and the signature form in general being lame this is a giant pain in the ass.
But I was bored...so here's a Python script that sets your sig to the current time. You'll need the Requests, BeautifulSoup and cfscrape packages to run it, then just set your username and password at the top of the file. Then you can alter the main function to use some file instead of the current time.
Spoiler
#! /usr/bin/env python import requests import re import cfscrape import bs4 import time SIG_URL = 'https://linustechtips.com/main/settings/signature/' LOGIN_URL = 'https://linustechtips.com/main/login/' MAIN_URL = 'https://linustechtips.com/main/' CSRF_RE = re.compile('csrfKey=(?P<csrf>[0-9A-Za-z]+)') USERNAME = 'XXX' PASSWORD = 'XXX' def _get_csrf(string): match = CSRF_RE.search(string) if match: return match.group('csrf') def _login(user, password, csrf, cookies): data = {'auth': user, 'csrfKey': csrf, 'login__standard_submitted': 1, 'password': password, 'remember_me': 0, 'signin_anonymous': 0, 'signin_anonymous_checkbox': 1} res = requests.post(LOGIN_URL, data=data, cookies=cookies) if res.status_code == 200: return res.history[0].cookies.get_dict() def _get_sig_form_data(cookies): res = requests.get(SIG_URL, cookies=cookies) if res.status_code != 200: return soup = bs4.BeautifulSoup(res.text, 'html.parser') return {'MAX_FILE_SIZE': (None, soup.find('input', {'name': 'MAX_FILE_SIZE'})['value']), 'plupload': (None, soup.find('input', {'name': 'plupload'})['value']), 'csrfKey': (None, soup.find('input', {'name': 'csrfKey'})['value']), 'view_sigs': (None, soup.find('input', {'name': 'view_sigs'})['value']), 'signature_upload': (None, soup.find('input', {'name': 'signature_upload'})['value'])} def _set_sig(sig, cookies): if sig[:3].lower() != '<p>': sig = '<p>' + sig + '</p>' data = _get_sig_form_data(cookies) data['view_sigs_checkbox'] = (None, '1') data['form_submitted'] = (None, '1') data['signature'] = (None, sig) res = requests.post(SIG_URL, files=data, cookies=cookies) if res.status_code != 200: return False return True def change_sig(sig): cookies, _ = cfscrape.get_tokens(LOGIN_URL) res = requests.get(MAIN_URL, cookies) if res.status_code != 200: print('Unabled to connect to LTT.') return csrf = _get_csrf(res.text) if not csrf: print('Unable to get CSRF token.') return cookies['ips4_IPSSessionFront'] = res.cookies['ips4_IPSSessionFront'] new_cookies = _login(USERNAME, PASSWORD, csrf, cookies) if not new_cookies: print('Unable to log in.') return cookies = dict(cookies, **new_cookies) if _set_sig(sig, cookies): print('Signature updated! Probably...') else: print('Unable to set signature.') def main(): change_sig(str(time.time())) if __name__ == '__main__': main()
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now