Created
October 22, 2022 08:45
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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