Http post and http get

Discussion in 'Python' started by n3d!m, Jan 25, 2012.

  1. n3d!m

    n3d!m Guest

    I am writing python script which will log into openSIS (Student information system) and get grades. Demo of website is available here: http://demo.os4ed.com/
    Here is code which works for that site:

    #!/usr/bin/python
    import requests
    user_login={'USERNAME':'student','PASSWORD':'student'}
    r=requests.post("http://demo.os4ed.com/index.php", data=user_login)
    r=requests.get("http://demo.os4ed.com/for_export.php?modname=Grades/Transcripts.php&modfunc=save&_openSIS_PDF=true&controller=Y&st_arr[]=1", cookies=r.cookies)
    print r.text

    My problem is when I try the same thing with my school's openSIS. It returns me error:
    <SCRIPT language=javascript>history.back();alert("You must choose at least one student and marking period");</SCRIPT>

    Their openSIS is installed on port 8080. Does port 8080 causes problem with my script?
     
    n3d!m, Jan 25, 2012
    #1
    1. Advertising

  2. n3d!m

    Jon Clements Guest

    On Jan 25, 10:23 pm, "n3d!m" <> wrote:
    > I am writing python script which will log into openSIS (Student information system) and get grades. Demo of website is available here:http://demo.os4ed.com/
    > Here is code which works for that site:
    >
    > #!/usr/bin/python
    > import requests
    > user_login={'USERNAME':'student','PASSWORD':'student'}
    > r=requests.post("http://demo.os4ed.com/index.php", data=user_login)
    > r=requests.get("http://demo.os4ed.com/for_export.php?modname=Grades/Transcripts.php&m...[]=1", cookies=r.cookies)
    > print r.text
    >
    > My problem is when I try the same thing with my school's openSIS. It returns me error:
    > <SCRIPT language=javascript>history.back();alert("You must choose at least one student and marking period");</SCRIPT>
    >
    > Their openSIS is installed on port 8080. Does port 8080 causes problem with my script?


    Why do you think a port number would make a difference? As long as the
    URI you're connecting to, correctly routes to something handling HTTP
    - it doesn't matter - and since you're getting "script" tags back, it
    implies it does.

    I think the response you're getting says it all, although:
    1) It should be "javascript" instead of javascript (tho' most of the
    time it's omitted)
    2) Can't fathom why the history.back() precedes the alert("...")
    3) It's normally more polite to go to an error page with an <a
    href="...">whatever</a> instead of an alert

    For stuff like this, I would use Firefox with Firebug, and manually go
    through the process of doing what you're doing, getting where the
    posts go etc... etc..., and then try and mimic that.

    ie, you find out where submissions take place and what data you
    retrieve, it might be that you just require a session cookie and then
    can by-pass pretty much all the intermediate pages.

    If pages are AJAX generated, it's quite a bit more work, you'll either
    need to run some form of web engine, or automate a browser using
    selenium. Then you should be able to use lxml.html to parse the DOM
    the browser has generated.

    hth,

    Jon.
     
    Jon Clements, Jan 26, 2012
    #2
    1. Advertising

  3. n3d!m

    n3d!m Guest

    Cookies work because I am able to login on website and GET other pages.
     
    n3d!m, Feb 6, 2012
    #3
    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. Lasse Seten

    HTTP POST and GET fails

    Lasse Seten, Jul 23, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    352
    Lasse Seten
    Jul 23, 2003
  2. ColinK
    Replies:
    0
    Views:
    544
    ColinK
    Jul 15, 2007
  3. arnuld
    Replies:
    6
    Views:
    615
    arnuld
    Sep 5, 2007
  4. serge calderara

    HTTP GET vs HTTP POST protocol

    serge calderara, Nov 4, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    608
  5. Fred
    Replies:
    17
    Views:
    258
Loading...

Share This Page