Inputting data into a website question
Benjamin Edwards
benjumanji at googlemail.com
Tue Apr 21 18:39:06 EDT 2009
On Apr 21, 11:10 pm, grocery_stocker <cdal... at gmail.com> wrote:
> 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/search.do?searchText=clothes&searchDivName=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...
More information about the Python-list
mailing list