Issues while logging in to bugzilla using python

94 Views Asked by At
import requests
from bs4 import BeautifulSoup
URL = "http://india-bugzilla/Games/index.cgi"
headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36'
}
login_data = {
    "username": "[email protected]",
    "password": "xxxx",
    "GoAheadAndLogIn": "Log in"
}
with requests.Session() as s:
    url = 'https://bugzilla.mozilla.org/home'
    r = s.get(url, headers=headers)
    soup = BeautifulSoup(r.content, 'html.parser')
    login_data['Bugzilla_login_token'] = soup.find('input', attrs={'id':'token_top'})['value']
    r = s.post(url, data=login_data, headers=headers)
    print(r.content)

It throws the below error "Bugzilla needs a legitimate login and password to continue." inside the HTML content.

0

There are 0 best solutions below