Created
December 9, 2011 21:30
-
-
Save k4rtik/1453381 to your computer and use it in GitHub Desktop.
An attempt to programmatically access NITC library's checkouts section to find out how many books are due by a particular date. Done on September 1, 2011.
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
# An attempt to programmatically access NITC library's checkouts section to find out how many books are due by a particular date. | |
# For some reason, the behaviour of the library site was different for different browsers - perhaps identifying and | |
# using proper browser UserAgent string could have made this script work. | |
import re | |
from mechanize import Browser | |
br = Browser() | |
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20100101 Firefox/6.0')] | |
br.open("http://library.nitc.ac.in:8080/webopac/html/checkouts") | |
br.select_form(name="form") | |
# Browser passes through unknown attributes (including methods) | |
# to the selected HTMLForm (from ClientForm). | |
br["txtmemberid"] = "<roll number here>" # (the method here is __setitem__) | |
response = br.submit() # submit current form | |
print response.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment