python urlopen parameters 1

python urlopen parameters

from BeautifulSoup import BeautifulSoup
import urllib

post_params = {
              'param1' : 'val1',
              'param2' : 'val2',
              'param3' : 'val3'
              }
post_args = urllib.urlencode(post_params)

url = 'http://www.sample.com/myASP.asp'
fp = urllib.urlopen(url, post_args)
soup = BeautifulSoup(fp)

Here is what the above code is Doing:
1. Create a dictionary of the parameters you want to pass to the ASP page.
2. Encode the parameters.
3. Open the URL and pass the encoded parameters.
4. Create a BeautifulSoup object from the response.

Similar Posts