Http post and http get

N

n3d!m

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.ph...ave&_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?
 
J

Jon Clements

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top