As for click method, but return a tuple (url, data, headers). You can use this data to send a request to the server. This is useful if you're using httplib or urllib rather than urllib2. Otherwise, use the click method. # Untested. Have to subclass to add headers
(self,
name=None, type=None, id=None,
nr=0, coord=(1,1),
request_class=_urllib.request.Request,
label=None)
| 3127 | self._request_class) |
| 3128 | |
| 3129 | def click_request_data(self, |
| 3130 | name=None, type=None, id=None, |
| 3131 | nr=0, coord=(1,1), |
| 3132 | request_class=_urllib.request.Request, |
| 3133 | label=None): |
| 3134 | """As for click method, but return a tuple (url, data, headers). |
| 3135 | |
| 3136 | You can use this data to send a request to the server. This is useful |
| 3137 | if you're using httplib or urllib rather than urllib2. Otherwise, use |
| 3138 | the click method. |
| 3139 | |
| 3140 | # Untested. Have to subclass to add headers, I think -- so use urllib2 |
| 3141 | # instead! |
| 3142 | import urllib |
| 3143 | url, data, hdrs = form.click_request_data() |
| 3144 | r = _urllib.request.urlopen(url, data) |
| 3145 | |
| 3146 | # Untested. I don't know of any reason to use httplib -- you can get |
| 3147 | # just as much control with urllib2. |
| 3148 | import httplib, urlparse |
| 3149 | url, data, hdrs = form.click_request_data() |
| 3150 | tup = urlparse(url) |
| 3151 | host, path = tup[1], _urllib.parse.urlunparse((None, None)+tup[2:]) |
| 3152 | conn = httplib.HTTPConnection(host) |
| 3153 | if data: |
| 3154 | httplib.request("POST", path, data, hdrs) |
| 3155 | else: |
| 3156 | httplib.request("GET", path, headers=hdrs) |
| 3157 | r = conn.getresponse() |
| 3158 | |
| 3159 | """ |
| 3160 | return self._click(name, type, id, label, nr, coord, "request_data", |
| 3161 | self._request_class) |
| 3162 | |
| 3163 | def click_pairs(self, name=None, type=None, id=None, |
| 3164 | nr=0, coord=(1,1), |