Skip to content

Instantly share code, notes, and snippets.

@SahbiOuali13
Created October 22, 2022 08:45
Show Gist options
  • Save SahbiOuali13/f1fe973bd795720c610446ac0131cd72 to your computer and use it in GitHub Desktop.
Save SahbiOuali13/f1fe973bd795720c610446ac0131cd72 to your computer and use it in GitHub Desktop.
Now break down the above example: 1. You create a Browser instance and use it to request the URL http://olympus.realpython.org/login. You assign the HTML content of the page to the login_html variable using the .soup property. 2. login_html.selec
import mechanicalsoup
# 1
browser = mechanicalsoup.Browser()
url = "http://olympus.realpython.org/login"
login_page = browser.get(url)
login_html = login_page.soup
# 2
form = login_html.select("form")[0]
form.select("input")[0]["value"] = "zeus"
form.select("input")[1]["value"] = "ThunderDude"
# 3
profiles_page = browser.submit(form, login_page.url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment