niklasb / webkit-server

[not actively maintained] The C++ webkit-server from capybara-webkit with useful extensions and Python bindings
MIT License
48 stars 38 forks source link

Fix encoding in forms #28

Open quique0194 opened 7 years ago

quique0194 commented 7 years ago

Fix #27

niklasb commented 7 years ago

Can you please explain to me what this pull request changes specifically and why you feel the changes are necessary.

quique0194 commented 7 years ago

I was working with some forms. I had to add some unicode data like "Nuñez" but the following error showed up:

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/ubuntu/apurata/app/scripts/fetch_sbs_data.py", line 85, in fetch_sbs_data
    ret, html = get_data_from_sbs(data, proxy=proxy, tries=10)
  File "/home/ubuntu/apurata/app/lib/sbs.py", line 140, in get_data_from_sbs
    html_text = get_sbs_html(data, tries, proxy=proxy)
  File "/home/ubuntu/apurata/app/lib/sbs.py", line 56, in get_sbs_html
    ).set(data["last_name_m"].encode('utf-8'))
  File "/usr/local/lib/python2.7/dist-packages/webkit_server.py", line 93, in set
    self._invoke("set", value)
  File "/usr/local/lib/python2.7/dist-packages/webkit_server.py", line 207, in _invoke
    return self.client.issue_node_cmd(cmd, "false", self.node_id, *args)
  File "/usr/local/lib/python2.7/dist-packages/webkit_server.py", line 377, in issue_node_cmd
    return self.conn.issue_command("Node", *args)
  File "/usr/local/lib/python2.7/dist-packages/webkit_server.py", line 518, in issue_command
    self._sock.sendall(arg.encode("utf-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128)