In this topic (https://www.simplemachines.org/community/index.php?topic=585067.0), you can see that SMF 1.1.21 authorizes fine through requests in Python.
I have to use Selenium with SMF 2.1. But in this way it takes a long time to load a long message into a topic.
What are the reasons why 2.1 refuses to work with requests? And how to fix it?
Your session timed out while posting. Please go back and try again.
I tried to fill in hidden fields, but to no avail.
Wow, that's an open ended question with no details...
If you actually want help, then providing things like, well maybe the script which you claim used to work?
I mean, the password system and encryption changed between versions. Very little written for 1.1.x will work on 2.1.x without modification
Well, that and the fact that 2.0 has session security that 1.x didn't so that external stuff needs changing...
Kindred , sorry for not showing the code earlier.
This worked fine on SMF 1.1.21:
payload = {
'user': 'login',
'passwrd': 'password',
'cookielength': '-1'
}
s = requests.Session()
p = s.post('http://site.com/index.php?action=login2', data=payload, timeout=10)
cookies = p.headers['smf_sc']
n_cookies = {}
m = re.compile('(\w+)=([a-z%0-9A-Z]+)[^;]*')
for (name, content) in re.findall(m, cookies):
if name != "expires":
n_cookies[name] = content
# create text content for form_data
r = s.post('http://site.com/index.php?action=post2;board=111.0', data=form_data,
cookies=n_cookies)
I tried collecting hidden fields on action=login and then using them on action=login2. But nothing works.
You need those hidden fields, and to supply the cookie with them as well, since the cookie contains the session ID that verifies if the other (multiple) hidden fields are correct.
Finally set up creating topics using requests. Threw away slow Selenium. :)