Skip to content

Instantly share code, notes, and snippets.

@k4rtik
Created December 9, 2011 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k4rtik/1453381 to your computer and use it in GitHub Desktop.
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.
# 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