Scrapy, a fast high-level web crawling & scraping framework for Python.
Allow button cotrols to submit form
Olaf Dietsche121d7535beb3
diff --git a/scrapy/http/request/form.py b/scrapy/http/request/form.pyindex 0b1d3b926..1920cefe1 100644--- a/scrapy/http/request/form.py+++ b/scrapy/http/request/form.py@@ -150,14 +150,16 @@ def _get_clickable(clickdata, form):if the latter is given. If not, it returns the firstclickable element found"""- clickables = [el for el in form.xpath('.//input[@type="submit"]')]+ clickables = [el for el in form.xpath('descendant::input[@type="submit"]'+ '|descendant::button[@type="submit"]'+ '|descendant::button[not(@type)]')]if not clickables:return# If we don't have clickdata, we just use the first clickable elementif clickdata is None:el = clickables[0]- return (el.name, el.value)+ return (el.get('name'), el.get('value'))# If clickdata is given, we compare it to the clickable elements to find a# match. We first look to see if the number is specified in clickdata,@@ -169,7 +171,7 @@ def _get_clickable(clickdata, form):except IndexError:passelse:- return (el.name, el.value)+ return (el.get('name'), el.get('value'))# We didn't find it, so now we build an XPath expression out of the other# arguments, because they can be used as such@@ -177,7 +179,7 @@ def _get_clickable(clickdata, form):u''.join(u'[@%s="%s"]' % c for c in six.iteritems(clickdata))el = form.xpath(xpath)if len(el) == 1:- return (el[0].name, el[0].value)+ return (el[0].get('name'), el[0].get('value'))elif len(el) > 1:raise ValueError("Multiple elements found (%r) matching the criteria ""in clickdata: %r" % (el, clickdata))