473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to fill a form

I need to fill form from web site, the code for this form looks like
this:

<form action="login.php" method="post" target="_top">

<input type="text" name="username" size="25" maxlength="40"
class="post" />
<input type="password" name="password" size="25" maxlength="25"
class="post" />

<input type="hidden" name="redirect"
value="" />
<input type="submit" name="login" class="mainoption"
value="Login" />

</form>

I can of course connect to a web site and download the form, i do it
like this:

import urllib2
www = urllib2.urlopen("http://www.site.com/login.php")
form_data= stronka.read()

or using httplib:

import httplib
conn = httplib.HTTPConnection("www.site.com")
conn.request("GET", "/login.php")
data1 = conn.getresponse().read()
but i can't fill and send this form is there some simple way to do it?
Aug 15 '06 #1
10 10881
Sulsa wrote:
I need to fill form from web site, the code for this form looks like
this:

<form action="login.php" method="post" target="_top">

<input type="text" name="username" size="25" maxlength="40"
class="post" />
<input type="password" name="password" size="25" maxlength="25"
class="post" />

<input type="hidden" name="redirect"
value="" />
<input type="submit" name="login" class="mainoption"
value="Login" />

</form>

I can of course connect to a web site and download the form, i do it
like this:

import urllib2
www = urllib2.urlopen("http://www.site.com/login.php")
form_data= stronka.read()

or using httplib:

import httplib
conn = httplib.HTTPConnection("www.site.com")
conn.request("GET", "/login.php")
data1 = conn.getresponse().read()
but i can't fill and send this form is there some simple way to do it?
I'd recommend you take a look at mechanize, see

http://wwwsearch.sourceforge.net/mechanize/

and specifically at ClientForm, see

http://wwwsearch.sourceforge.net/ClientForm/

These make it easy to perform browser-like accesses to forms-based web
applications.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Aug 15 '06 #2
On Tue, 15 Aug 2006 03:22:40 +0100
Steve Holden <st***@holdenweb.comwrote:
I'd recommend you take a look at mechanize, see

http://wwwsearch.sourceforge.net/mechanize/

and specifically at ClientForm, see

http://wwwsearch.sourceforge.net/ClientForm/

These make it easy to perform browser-like accesses to forms-based
web applications.
I want to fill only one smiple form so i would like not to use any non
standard libraries.
Aug 15 '06 #3
On 2006-08-15, Sulsa <su***@gazeta.plwrote:
I want to fill only one smiple form so i would like not to use
any non standard libraries.
Then just send the HTTP "POST" request containing the fields
and data you want to submit.

--
Grant Edwards grante Yow! LBJ, LBJ, how many
at JOKES did you tell today??!
visi.com
Aug 15 '06 #4
Sulsa wrote:
On Tue, 15 Aug 2006 03:22:40 +0100
Steve Holden <st***@holdenweb.comwrote:

>>I'd recommend you take a look at mechanize, see

http://wwwsearch.sourceforge.net/mechanize/

and specifically at ClientForm, see

http://wwwsearch.sourceforge.net/ClientForm/

These make it easy to perform browser-like accesses to forms-based
web applications.


I want to fill only one smiple form so i would like not to use any non
standard libraries.
That's your choice, but frankly I'd be very surprised if it wasn't
quicker to download and use mechanize/clientform than it was to put your
own solution together.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Aug 15 '06 #5
On Tue, 15 Aug 2006 03:37:02 -0000
Grant Edwards <gr****@visi.comwrote:
On 2006-08-15, Sulsa <su***@gazeta.plwrote:
I want to fill only one smiple form so i would like not to use
any non standard libraries.

Then just send the HTTP "POST" request containing the fields
and data you want to submit.
but i don't know how to post these data if i knew there there would
be no topic.
Aug 15 '06 #6
On Monday 14 August 2006 20:43, Sulsa wrote:
On Tue, 15 Aug 2006 03:37:02 -0000

Grant Edwards <gr****@visi.comwrote:
On 2006-08-15, Sulsa <su***@gazeta.plwrote:
I want to fill only one smiple form so i would like not to use
any non standard libraries.
Then just send the HTTP "POST" request containing the fields
and data you want to submit.

but i don't know how to post these data if i knew there there would
be no topic.
When I need to learn the POST method for a form, I use wireshark
(www.wireshark.org) to capture the POST I do manually the first time.
However, I think I'm going to look into mechanize/clientform now that I
know about it.

Hope this helps,
Tom
Aug 15 '06 #7
Sulsa wrote:
but i don't know how to post these data if i knew there there would
be no topic.
http://docs.python.org/lib/module-urllib.html

You want to look at urlopen and urlencode.

But if you mean you don't know what fields and data to use, then you
need a HTML reference, not a Python one.
Aug 15 '06 #8
Sulsa <su***@gazeta.plwrites:
On Tue, 15 Aug 2006 03:37:02 -0000
Grant Edwards <gr****@visi.comwrote:
On 2006-08-15, Sulsa <su***@gazeta.plwrote:
I want to fill only one smiple form so i would like not to use
any non standard libraries.
Then just send the HTTP "POST" request containing the fields
and data you want to submit.

but i don't know how to post these data if i knew there there would
be no topic.
Something like this (UNTESTED, and I can never remember all the
details, which are fiddlier than they may look):

import urllib, urllib2
query = urllib.urlencode([
("username", "sulsa"), ("password", "sulsa"),
("redirect", ""), ("login", "Login"),
])
r = urllib2.urlopen("http://example.com/login.php", query)
print r.read()
Note that urllib and urllib2 both, as their main job in life, open
URLs. urllib also has miscellaneous functions related to URLs &c. I
use urllib2 above because I know it better and because it can handle
some stuff that urllib doesn't (it's designed more for extensibility
than is urllib).
John
Aug 17 '06 #9
Sulsa wrote:
On Tue, 15 Aug 2006 03:37:02 -0000
Grant Edwards <gr****@visi.comwrote:
>On 2006-08-15, Sulsa <su***@gazeta.plwrote:
I want to fill only one smiple form so i would like not to use
any non standard libraries.

Then just send the HTTP "POST" request containing the fields
and data you want to submit.

but i don't know how to post these data if i knew there there would
be no topic.
You forgot thanks and regards

Aug 17 '06 #10
Sulsa wrote:
On Tue, 15 Aug 2006 03:37:02 -0000
Grant Edwards <gr****@visi.comwrote:
On 2006-08-15, Sulsa <su***@gazeta.plwrote:
I want to fill only one smiple form so i would like not to use
any non standard libraries.
Then just send the HTTP "POST" request containing the fields
and data you want to submit.

but i don't know how to post these data if i knew there there would
be no topic.
http://aspn.activestate.com/ASPN/Coo.../Recipe/146306

Aug 18 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Scott | last post by:
Hi there, I have a PDF that has editable form fileds. I want to be able dynamically fill in those form fields based on values I provide to the PDF. Right now, I can create an instance of the...
2
by: Terry | last post by:
Hi, I am trying to figure how to do the following: I have 2 pages, Page 1 has a simple form with a field called "Number", and Page 2 has a button. Whenever the button on Page 2 is clicked,...
1
by: mikeybe | last post by:
Making a very simple library circulation database for a school project. I have a Patron Information table(patronID, first name, last name, phone) , an item information table (bookID, book title,...
2
by: Joanne Lewis | last post by:
I am having a great deal of difficulty with a form. Basically, I would like to enter an account # and have the account #, patient first name, and patient last name automatically fill. The form...
0
by: dbuchanan | last post by:
Hello, I have added a query to my TableAdapter that accepts a parameter (The ID) to filter the data. It will return only one record. I tested it in the designer and it returns one record as...
19
by: Alex | last post by:
Hello list This question has probably already been asked, but let me ask again I have a mysql database to which I connect with my php scripts. The database contains articles. Name, Unit_Price...
1
by: adjaco | last post by:
Hi - New here......and desperate! My boss dropped an Access problem on my desk and I know almost nothing about Access. I have figured out a way to input most of the data in a form but I want to...
1
by: lnong | last post by:
Im using the ActivePDF Toolkit to programmatically fill in a PDF document using .NET. I have a mulitline textfield (textbox), and I want to be able to insert a newline character. I cannot find a...
106
by: bonneylake | last post by:
Hey Everyone, Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all...
7
by: ghjk | last post by:
I have table which is clickable.When user click one record I want to call java script function and fill the form using selected values. This is my code and I can't understand what is going...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.