AW: [Zope] Source from form result.

Thomas B. Passin tpassin@mitretek.org
Wed, 2 May 2001 18:21:45 -0400


[Marc Fischer]

> Ok, I will try to explain. ... Somewhere in the Web, there is a Website,
out
> of the world of zope:-), that provides a form with a submit button. this
> form passes some arguments with the syntax:
> <input type="hidden" name="x" value="y"> ...
>
> If you klick on submit button, you get displayed some pictures. so far so
> good ...
>
> I want to create a zope application, that automatically gets the source of
> this result page, extracts the urls of the picutres and finally uploads
> these pictures into my zopeserver.

[Tom]
You mean, you have a web page hosted in Zope, you click a button or
something on it, and the pictures end up in Zope with no more human actions?

[Marc]
>
> The problem is, that it is not possible to pass the variables in the url
> like this:
> http://server/index.html?x=y.
>
>
[Tom]
I don't know what you mean here, why can't you include the variables in the
url?  Where would you like to include the variables but find it can't be
done?

[Marc]
> So I am looking for a way of being able to handle the source code of this
> result. Extraction of the urls is not a problem.
>
[Tom]
Do you want to do this for a single site that always sends the same html, or
a range of sites that are similar but not identical?

I would think about using an External Method.  That would let you use the
Python httplib library.  With httplib , you could get the form by issuing an
HTTP GET command on the remote server.  Then you could use the form to build
the right url (including the "?x=y"), and then issue another GET on that
url. This would get you the html for the page - that is the source you asked
for - from which you could extract all the image urls.  This wouldn't work
if the form runs some javascript to set its variables, though, since your
Python program wouldn't be able to figure out what the javascript was doing.

Alternatively, if the form you want has a name assigned to the form element
(or even if you knew its position among all the forms on the page), you
could create a browser window with two frames and load the form into one of
them.  From the other one, using Javascript, you could cause the form to
load the page that has the pictures.  Then, again with javascript, you could
walk through its images array and get all the urls.  Then you could load
these urls into form variables and, using javascript, send the form with the
pictures' urls to Zope.  From there, it ought to be possible to get Zope to
upload the pictures.

If you were clever with the design, you could get your page to do this on a
list of sites, or on a list of picture selections.

I think this would be feasible using either Netscape or Internet Explorer,
but certainly with IE.

We're talking about a lot of work experimenting and developing, though, if
you don't know these techniques already.  How many images do you want to
capture?  Maybe it would be faster to do them by hand, one at a time.

Cheers,

Tom P