Programmatically log in and request XML

Discussion in 'Python' started by Tim Johnson, Apr 18, 2011.

  1. Tim Johnson

    Tim Johnson Guest

    FYI: Using python 2.7 on ubuntu 10.04.

    I have acquainted myself with the parsing of XML data using an input file as
    test data. Now I need to make a request the feed itself, and capture
    that field as data.

    I need to do the following:
    1)Programmatically log into a site with user and password.
    2)Make a GET request to a site under the same domain.

    Since I have used urllib2 in the past,
    >From http://docs.python.org/library/urllib2.html

    I am offering a modification of the example under the heading:
    """
    Use of Basic HTTP Authentication
    """
    import urllib2
    # Create an OpenerDirector with support for Basic HTTP Authentication...
    auth_handler = urllib2.HTTPBasicAuthHandler()
    auth_handler.add_password(realm=None,
    uri='http://retsgw.flexmls.com:80/rets2_0/Login',
    user='******',
    passwd='******')
    opener = urllib2.build_opener(auth_handler)
    # ...and install it globally so it can be used with urlopen.
    urllib2.install_opener(opener)
    urllib2.urlopen('http://retsgw.flexmls.com/rets2_0/GetMetadata?Type=METADATA-TABLE&ID=Property:A&Format=STANDARD-XML')

    Am I at the correct starting point?
    If so, I can take it from there
    If not,
    Can someone recommend a better approach?

    thanks
    --
    Tim
    tim at johnsons-web dot com or akwebsoft dot com
    http://www.akwebsoft.com
     
    Tim Johnson, Apr 18, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Birtle
    Replies:
    2
    Views:
    2,103
    John Saunders
    Oct 16, 2003
  2. Henrik_the_boss
    Replies:
    0
    Views:
    2,681
    Henrik_the_boss
    Nov 5, 2003
  3. Tony Pino
    Replies:
    5
    Views:
    647
    Tony Pino
    Dec 3, 2003
  4. Amratash
    Replies:
    0
    Views:
    547
    Amratash
    Apr 13, 2004
  5. AAaron123
    Replies:
    1
    Views:
    286
    Cowboy \(Gregory A. Beamer\)
    Oct 14, 2008
Loading...

Share This Page