Inputting data into a website question

G

grocery_stocker

Let's say that I have a file with the following words
shirt
jeans
belt
jacket

Now I want to be able to enter these words into the search function at
the following website..

http://oldnavy.gap.com/?redirect=true

Is there some method in the urllib method that would allow me to do
this? I tried googling this, but all I found was stuff related to CGI.
 
B

Benjamin Edwards

Let's say that I have a file with the following words
shirt
jeans
belt
jacket

Now I want to be able to enter these words into the search function at
the following website..

http://oldnavy.gap.com/?redirect=true

Is there some method in the urllib method that would allow me to do
this? I tried googling this, but all I found was stuff related to CGI.

Have you considered looking at the urls that you are posting to?

http://oldnavy.gap.com/browse/searc...archDivName=Baby+Girls&submit.x=16&submit.y=5

I think the pattern to spot here is not too hard ;)

"...?searchText=%(search_term)s&searchDivName=%(select_val)
&submit.x=5&submit.y=5" % {values:here}

submit just seems to be caputuring the click co-ordinated on the
button. There is also some post data being sent to a different url,
but I haven't investigated it yet. In any case it shouldn't be very
difficult to iterate through your search terms and get the http back.

import urllib
fsock = open(myterms.txt)
for lines in fsock: 1
sock = urllib.urlopen("http://url/" % (search,terms,in,line)) 2
htmlSource = sock.read() 3
sock.close() 4
print htmlSource

or something like that...
 
E

Emile van Sebille

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top