Python Forum
RoboBrowser error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: RoboBrowser error (/thread-16983.html)



RoboBrowser error - Pythenx - Mar-23-2019

This code should go to the mp3 converter page and fill in the form with "just an example". It shows an error, which I don't know how to fix. I tried looking it up but didn't find anything. I would appreciate any kind of help very much. Thanks in advance!

from robobrowser import RoboBrowser


br = RoboBrowser()
br.open("https://ytmp3.cc/")
form = br.get_form()
form['input'] = 'just an example'
br.submit_form(form)
I tried doing the instructions what the error message said, but I don't know how to that exactly. Here is the line in which the error is caused and in which I probably need to pass the additional argument...

    def parsed(self):
        """Lazily parse response content, using HTML parser specified by the
        browser.
        """
        return BeautifulSoup(
            self.response.content,
            features=self.browser.parser
        )
Error:
C:\Users\Valdis\PycharmProjects\automated\venv\lib\site-packages\robobrowser\browser.py:40: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently. The code that caused this warning is on line 40 of the file C:\Users\Valdis\PycharmProjects\automated\venv\lib\site-packages\robobrowser\browser.py. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor. features=self.browser.parser Traceback (most recent call last): File "C:/Users/Vald/PycharmProjects/automated/youtube.py", line 7, in <module> form['input'] = 'just an example' File "C:\Users\Vald\PycharmProjects\automated\venv\lib\site-packages\robobrowser\forms\form.py", line 216, in __setitem__ self.fields[key].value = value File "C:\Users\Vald\PycharmProjects\automated\venv\lib\site-packages\werkzeug\datastructures.py", line 794, in __getitem__ raise exceptions.BadRequestKeyError(key) werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.



RE: RoboBrowser error - mlieqo - Mar-23-2019

It seems that you need to access form elements with their name attributes, you can see this if you print out your 'form' var:
Output:
<RoboForm video=>
and then change the value of this element with:
form['video'].value = 'just an example'



RE: RoboBrowser error - metulburr - Mar-23-2019

I would suggest to use requests library or mechanize (or selenium if your stuck on javascript). RoboBrowser seems to have stalled development. The last update was 4 years ago and the whole project last one year total. It seems more like a college student project that he moved on. There is also more help for those libraries as they are more well known. I havent even heard about robobrowser until this thread. They are also more well developed and more features.