Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Http post and http get

Reply
Thread Tools

Http post and http get

 
 
n3d!m
Guest
Posts: n/a
 
      01-25-2012
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':'stude nt'}
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&con troller=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?


 
Reply With Quote
 
 
 
 
Jon Clements
Guest
Posts: n/a
 
      01-26-2012
On Jan 25, 10:23*pm, "n3d!m" <(E-Mail Removed)> 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':'stude nt'}
> 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.

 
Reply With Quote
 
 
 
 
n3d!m
Guest
Posts: n/a
 
      02-06-2012
Cookies work because I am able to login on website and GET other pages.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP SOAP/HTTP GET/HTTP POST milan_9211 Software 0 01-10-2011 02:10 PM
HTTP::Post - HTTP::Get (Can someone help me?) Fred Ruby 17 04-25-2008 07:12 PM
How to send a http::get or http::post with a cookie? mrpink Ruby 2 04-22-2007 07:57 AM
HTTP GET vs HTTP POST protocol serge calderara ASP .Net Web Services 1 11-04-2005 01:27 PM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM



Advertisments