0 Replies - 4527 Views - Last Post: 24 July 2012 - 07:56 PM Rate Topic: -----

#1 dboltz03  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 12
  • Joined: 04-December 11

Using pycurl with pages with drop down lists

Posted 24 July 2012 - 07:56 PM

I am able to post webforms using pycurl, but recently I've run into a problem posting values for drop down lists. See the following example:

<select class="input_large_300 country_select" id="country_id" name="country[country_id]">
<option value=""></option>
<option value="106">US</option>
<option value="280">Mexico</option>
<option value="399">Canada</option>

I'm using the following code to post:
mydata = [('country_id', '399')]
    mydata = urllib.urlencode(mydata)
    path = 'http://www.somewebsite.com/submitted'
    myheader = ["Content-type: application/x-www-form-urlencoded"]
    pycurl_con.setopt(pycurl.POSTFIELDS, mydata)
    pycurl_con.setopt(pycurl.HTTPHEADER, myheader)
    storage = StringIO()
    pycurl_con.setopt(pycurl.URL, path)
    pycurl_con.setopt(pycurl.PROXY, 'localhost')    # Assuming Tor is on the same machine
    pycurl_con.setopt(pycurl.PROXYPORT, 9050)       # The port Tor runs through
    pycurl_con.setopt(pycurl.PROXYTYPE, pycurl.PROXYTYPE_SOCKS5)
    pycurl_con.setopt(pycurl.WRITEFUNCTION, storage.write)

Like I said, this code works for posting when I'm not dealing with drop down lists. Is there something wrong with what I have here? And does anyone know of any websites that have a large number of examples of posting with pycurl in many different scenarios?

Any help would be appreciated. Thanks!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1