[Tutor] Accessing query results html frame

Karim karim.liateni at free.fr
Fri Feb 11 08:51:46 CET 2011


Hello,

In fact as found in the net:

"The concept of browser frames is completely outside the scope of HTTP. 
However, browser frames are defined in HTML, and so is the target 
property on form elements: <form action="/somescript?x=y" 
method="POST" target="_top"> This will make the form submit to the 
_top frame, which means "use the full browser window" "

That means that my post form:

<FORM METHOD="POST" ACTION="/ddts/ddts_main" 
ENCTYPE="application/x-www-form-urlencoded" TARGET="rightframe">

has a target property to make the submit to the 'rightframe'.

Any ideas how I can modified the code (I think the request data or 
whatever) below to access without knowing the temporary html file name 
generically.

Regards
Karim

On 02/10/2011 07:12 PM, Karim wrote:
>
> Hello All,
>
> I get from Steven an very useful link (void space) for http 
> authentication. I added some codes to be
> able to POST FORM a query as I do it by clicking a query button to get 
> a list of bug Id on a server.
> The problem is I get a html page which refers 2 frames. And I am 
> interesting in one particular frame
> namely for example,
>  http://{server}:{port}/wt/tmp/results:karim.liateni.31_3917.html'.format(server=server, 
> port=port).
> But this pages is created every times in a tmp directory each time 
> with a different name.
>
> 1) How can I get the name of this page because with python the page 
> resulting of my query is not mentionned (hidden like)?
> Interactively there are 3 frames but only this one is of interest for 
> me. But no name of this page is visible in the main html page.
> Is there a method to get all the nested frames locations?
>
> 2) I can see this page interactively when I click on a submit query 
> button. Do I need to add 'ACTION': "Query" <input form
> in the query dictionnary to simulate a click for submission 
> (type="submit" button) ?
>
> 3) Interactively I see that cgi arg NextForm is empty so I let it like 
> that in my query and LastForm was set to "SavedQuery". I put the
> same value in my python code. Is this ok?
>
> import urllib
> import urllib2
>
> server='dummy.com'
> port='8081'
>
> username = 'karim.liateni'
> password = 'dummy_pass'
>
> theurl = 'http://{server}:{port}/ddts/ddts_main'.format(server=server, 
> port=port)
> #theurl = 
> 'http://{server}:{port}:8081/wt/tmp/results:karim.liateni.31_3917.html'.format(server=server, 
> port=port)
>
> #MEMO:
> #<FORM METHOD="POST" ACTION="/ddts/ddts_main" 
> ENCTYPE="application/x-www-form-urlencoded" TARGET="rightframe">
>
> data = {
>        'NextForm': "",
>        'LastForm': "SavedQuery",
>        'prompted': "yes",
>        'class': "Development",
>        'personalQuery': "DKPV",
>        'REMOTE_USER': username,
>        'QS': "  -p DKPVALIDATION_PLUGIN \(Class 'isequal' 
> &quot;Development&quot; \)",
>        'use_field_defs':"false",
>        'QueryName': "DKPV",
>        'QueryType': "personal",
>        'ACTION': "Query"
>        }
>
> query   = urllib.urlencode(data)
> request = urllib2.Request(theurl, query)
>
> passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
> passman.add_password(None, theurl, username, password)
> authhandler = urllib2.HTTPBasicAuthHandler(passman)
>
> opener = urllib2.build_opener(authhandler)
> urllib2.install_opener(opener)
>
> pagehandle = urllib2.urlopen(request)
> print(pagehandle.read())
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list