same, but use requests.cookie instead
e.g.
import requests
import json
import os
import random, string
from bs4 import BeautifulSoup
from requests_toolbelt import MultipartEncoder

cookie = requests.cookies.RequestsCookieJar()
if os.path.exists('cookies'):
    cookie.load(ignore_discard=True, ignore_expires=True)

session = requests.Session()
session.cookies = cookie

response = 
session.get('https://stifix.pythonanywhere.com/accounting/default/user/login')

data = { 'username':"user0", 'password':"password", 'remember_me':"on" }
print(data)

BS = BeautifulSoup(response.text, 'html.parser')
for i, e in enumerate(BS.select('input[name]')):
    print(i, e)
    if (e['name'][0] == '_'):
        data[e['name']] = e['value']

m = MultipartEncoder(fields=data)
print(m)

headers = {
    'Content-Type': m.content_type
}
print(headers)

response = 
session.post('https://test.pythonanywhere.com/accounting/default/user/login', 
data = m, headers = headers)
print(response.url)

response = 
session.get('https://test.pythonanywhere.com/accounting/default/user/profile')
print(response.url)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c5006ddd-71b8-4fa6-8902-f58726c6df86n%40googlegroups.com.

Reply via email to