Giter VIP home page Giter VIP logo

Comments (2)

yrammos avatar yrammos commented on July 24, 2024

Here is the example in its entirety:

>>> from robobrowser import RoboBrowser
>>> browser = RoboBrowser()
>>> browser.open('http://russianlearn.com')
>>> form = browser.get_form(class_='searchformredbutton')
>>> form['sword'].value = 'cat'
>>> browser.submit_form(form)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/robobrowser/browser.py", line 347, in submit_form
    response = self.session.request(method, url, **send_args)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 553, in send
    adapter = self.get_adapter(url=request.url)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 608, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'javascript:void(0)'
>>>

and the corresponding chunk of HTML:

<form class="searchformredbutton" style="margin-bottom:10px;margin-top:5px;" onsubmit="submitFormShadowbox();" action="javascript:void(0)" name="sForm">

    <input class="keyboardInput" type="text" value="" maxlength="100" name="sword"></input>
    <img class="keyboardInputInitiator" src="http://russianlearn.com/keyboard.png" alt="Virtual Keyboard Interface" title="Display virtual keyboard interface"></img>
    <input class="submitred" type="submit" value=""></input>

</form>```

from robobrowser.

jmcarp avatar jmcarp commented on July 24, 2024

It looks like the form you're trying to submit uses javascript. Robobrowser doesn't evaluate javascript, so making this work will require a little extra work. It looks like submitting the form is supposed to send an ajax request to http://russianlearn.com/setvar.php. To make that work, you might try something like this:

form.action = 'http://russianlearn.com/setvar.php'
browser.submit_form(form)

Or, since the ajax request returns data and not HTML, you might want to use the browser's session to make the request:

resp = browser.session.get('http://russianlearn.com/setvar.php', params={'value': 'cat'})

I'm going to close the issue, since working with javascript is beyond the scope of this library, but feel free to follow up if the suggestions above don't work for you. Thanks for reporting, and sorry for the very slow response!

from robobrowser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.