https://github.com/moriyoshi/lxmlmechanize
https://github.com/moriyoshi/lxmlmechanize
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/moriyoshi/lxmlmechanize
- Owner: moriyoshi
- Created: 2013-07-03T08:10:43.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-11-16T09:50:48.000Z (over 9 years ago)
- Last Synced: 2025-03-07T02:49:06.800Z (2 months ago)
- Language: Python
- Size: 133 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.txt
Awesome Lists containing this project
README
.. contents::
Introduction
============lxmlmechanize is an efficient, i18n-aware, simple, lxml-based HTTP user-agent.
Synopsis
========::
from lxmlmechanize import default_keychain, Mechanize
from lxmlmechanize.urllib2ext import Credentialsm = Mechanize()
# set credentials for authentication
default_keychain.add(Credentials('http://localhost:12345/', realm=None, user='test', password='testtest'))# navigate to the page
m.navigate('http://localhost:12345/')# populate the form fields
form = m.page.root.xpath('body//form[@id="test"]')[0]
form.xpath('input[@name="user"]')[0].set('value', 'user')
form.xpath('input[@name="password"]')[0].set('value', 'password')# submit the form
m.submit_form(form)