Error sending form in Mechanize

2

I am trying to autocomplete a form but I submit an error.

I show my code explained by parts:

import mechanize
import cookielib
import ssl

ssl._create_default_https_context = ssl._create_unverified_context

br = mechanize.Browser()
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
br.set_handle_robots(False)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; es-VE; rv:1.9.0.1)Gecko/2008071615 Debian/6.0 Firefox/9')]
r = br.open('https://www.ventas.com/insertar-anuncio.html')
print br.response().read()

until then everything is fine

br.select_form(nr=0)
print br.form  

that shows me the form parameters that are these

<insertad post //www.ventas.com/ multipart/form-data
  <TextControl(ad_price=9999)>
  <SelectControl(category=[*, 31, 32, 33, 214, 34, 213, 39, 43, 35, 36, 37, 40, 41, 42, 38, 211, 217, 219, 221, 44, 121, 122, 215, 125, 124, 123, 204, 101, 102, 103, 104, 105, 161, 162, 83, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 220, 82, 2, 3, 5, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 18, 19, 216, 218, 20])>
  <TextControl(ad_headline=)>
  <TextareaControl(ad_text=)>
  <HiddenControl(MAX_FILE_SIZE=307200) (readonly)>
  <FileControl(ad_picture_a=<No files added>)>
  <HiddenControl(MAX_FILE_SIZE=307200) (readonly)>
  <FileControl(ad_picture_b=<No files added>)>
  <HiddenControl(MAX_FILE_SIZE=307200) (readonly)>
  <FileControl(ad_picture_c=<No files added>)>
  <TextControl(email=)>
  <RadioControl(email_enabled=[*1, 0])>
  <TextControl(name=)>
  <TextControl(phone=)>
  <TextareaControl(recaptcha_challenge_field=)>
  <HiddenControl(recaptcha_response_field=manual_challenge) (readonly)>
  <SubmitControl(send_form=Enviar) (readonly)>
  <IgnoreControl(cancel_form=<None>)>>

filled those values

br.form['ad_price'] = '9959'
br.form['category'] = ['31']
br.form['ad_headline'] = 'HDD 1TB INTERNO PARA PC NEW SATA EN 70 LLAMAR 55108480'
br.form['ad_text'] = 'HDD 1TB'
br.form['email'] = '[email protected]'
br.form['name'] = 'yoandy'
br.form['phone'] = '55108480'
br.form['recaptcha_challenge_field'] = 'Daronta Avenue'

and when submitting the form with response = br.submit() I get the following error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nodo/.local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 685, in submit
    return self.open(self.click(*args, **kwds))
  File "/home/nodo/.local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 676, in click
    return self._add_referer_header(request)
  File "/home/nodo/.local/lib/python2.7/site-packages/mechanize/_mechanize.py", line 206, in _add_referer_header
    scheme = request.get_type()
  File "/home/nodo/.local/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 187, in get_type
    raise ValueError("unknown url type: %s" % self.__original)
ValueError: unknown url type: //www.ventas.com/

They could help me

    
asked by Yoandy Isse Oña 24.01.2018 в 02:04
source

0 answers