I'm pretty new to coding and self-teaching. I've been trying to create a viewers bot that will take usernames + passwords from a text file and login to a website go to a specific chat room with a proxy and stay in that room until I stop the script. But seems I'm stuck at page login. Any explanation would be greatly appreciated.
from bs4 import BeautifulSoup import requests from lxml.html import fromstring def get_proxies(): url = 'https://www.sslproxies.org/' response = requests.get(url) parser = fromstring(response.text) proxies = set() for i in parser.xpath('//tbody/tr')[:10]: if i.xpath('.//td[7][contains(text(),"yes")]'): proxy = ":".join[i.xpath('.//td[1]/text()'[0], i.xpath('.//td[2]/text()')[0])] proxies.add(proxy) return proxies # Login def login(): username = input("Please enter your username") password = input("Please enter your password") for line in open("user_accounts.txt", "r").readlines(): login_info = line.split() if username == login_info[0] and password == login_info[1]: print("Correct Credentials") return True print("Incorrect Credentials.") return False # URL to Login To payload = {"username":"<username>", "password":"<password>", "login":"<login>"} session_requests = requests.session() login_url = "https://www.example.com" result = session_requests.get(login_url) html = login_url tree = html.fomstring(result.text) result = session_requests.post(login_url, data = payload, headers = dict(referer=login_url)) url = 'https:www.exmaple.com' result = session_requests.get(url, headers = dict(referer = url)) tree = html.fromstring(result.content) bucket_names = tree.xpath("//div[@class='repo-list--repo']/a/text()") print(bucket_names) result.ok result.status_code