- fields = dict(re.findall(r'''(?x)type="hidden"\s+
- name="(.+?)"\s+
- value="(.*?)"
- ''', webpage))
- post = compat_urllib_parse.urlencode(fields)
- req = compat_urllib_request.Request(url, post)
- req.add_header('Content-type', 'application/x-www-form-urlencoded')
+ chash = self._search_regex(
+ r'val\("([^"]*)"\s*\+\s*\$\("#chash"\)', webpage, 'chash')
+ fields = self._hidden_inputs(webpage)
+ keys = list(fields.keys())
+ chash_key = keys[0] if len(keys) == 1 else next(
+ key for key in keys if key.startswith('cha'))
+ fields[chash_key] = chash + fields[chash_key]
+