def make_page_soup(cls, html): """Returns BeautifulSoup object from a html. :param html: str :return: object :rtype: BeautifulSoup """ return make_soup(html)
def login(self): try: response = requests.get(urljoin(self.url, self.token_page_path), auth=(self.user, self.password), cookies=self.cookies) self.csrf_token = make_soup(response.text).find(id='token').text if not self.csrf_token: raise UTorrentRPCException('Unable to fetch CSRF token.') self.cookies = response.cookies except Exception as e: LOGGER.error('Failed to login using `%s` RPC: %s' % (self.url, e.message)) raise UTorrentRPCException(e.message)
def login(self): try: response = requests.get(urljoin(self.url, self.token_page_path), auth=(self.user, self.password), cookies=self.cookies) self.csrf_token = make_soup(response.text).find(id='token').text if not self.csrf_token: raise UTorrentRPCException('Unable to fetch CSRF token.') self.cookies = response.cookies except Exception as e: LOGGER.error('Failed to login using `%s` RPC: %s', self.url, e.message) raise UTorrentRPCException(e.message)