(Sep-01-2018, 07:41 PM)eddywinch82 Wrote: The Company I have paid to help me with this code, have sorted the Login Problem they say.You have to use session in rest code after log in,is not used now.
Can show how to do test.
import sys import getpass import hashlib import requests import os, time from bs4 import BeautifulSoup BASE_URL = 'https://www.flightsim.com/' LOGIN_PAGE = 'https://www.flightsim.com/vbfs/login.php?do=login' def do_login(credentials): session = requests.Session() session.get(BASE_URL) req = session.post(LOGIN_PAGE, params={'do': 'login'}, data=credentials) if req.status_code != 200: print('Login not successful') sys.exit(1) # session is now logged in return session def get_credentials(): username = 'aaaa' password = 'xxxxxx' password_md5 = hashlib.md5(password.encode()).hexdigest() return { 'cookieuser': 1, 'do': 'login', 's': '', 'securitytoken': 'guest', 'vb_login_md5_password': password_md5, 'vb_login_md5_password_utf': password_md5, 'vb_login_password': '', 'vb_login_password_hint': 'Password', 'vb_login_username': username, } credentials = get_credentials() session = do_login(credentials) # Check that logged in time.sleep(3) url_in = 'https://www.flightsim.com/vbfs/forum.php' resonse = session.get(url_in) print(resonse) soup = BeautifulSoup(resonse.content, 'lxml') welcome = soup.find('h2', class_="forumtitle") print(welcome.text)
Output:<Response [200]>
Newcomer Services
So example in line 54 it most be session.get(url)
If you paid they should help you to get started and have some working code that download some zip files.