Access Database Using Python

Karthish karthish at gmail.com
Mon Jun 13 15:50:00 EDT 2005


I'm writing a script to look through DNA sequences in a database and
select sequences I require. So far, my code looks like this for
authentication:

import os
import Bio.Clustalw
from Bio.Alphabet import IUPAC
import pdb
import sys
import os
import urllib
import urllib2


import urllib
userid = 'kmdawg'
password = 'kmdawgyeah'
location = 'index.html'
params = urllib.urlencode({'user': userid, 'password': password,
'request_uri': location})
f = urllib2.urlopen("http://www.gene-regulation.com/login?%s" % params)
print f.read()

When I run the program, I see the following:
______________

<HTML>
<HEAD>
  <TITLE>Redirect</TITLE>
  <META http-equiv="pragma" content="no-cache">
  <META http-equiv="cache-control" content="no-cache">
  <META http-equiv="expires" content="0">
  <META http-equiv="refresh" content="1; URL=index.html"></HEAD><BODY
bgcolor="white">
<h1>Please stand by, you will be redirected
toindex.html...</h1></body></html>
________________

The code works as it is. How would I modify this script to display the
page
"http://www.gene-regulation.com/cgi-bin/pub/databases/transfac/getTF.cgi?AC=R00077"?
I can't figure out how to authenticate and then load a page, since the
page requires cookies for authentication. 

Thanks.




More information about the Python-list mailing list