Lua Scripting - Submiting via JS
See original GitHub issueHi,
I’ve been having trouble getting a lua script that calls something like:
splash:runjs("$(':submit')[0].click()")
to run. That is, splash doesn’t seem to actually render the result of the page after submission - as if the submit button had been clicked in the first place.
Any idea how to work around this or what I may be doing wrong?
Thanks, Alex
Issue Analytics
- State:
- Created 8 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Javascript - communicate with Lua script - Stack Overflow
I have my responsive front-end based on Bootstrap. What I want to do is send command data from Javascript to a Torch Lua...
Read more >A Beginner's Guide to Web Scripting with Lua and Fengari.
Fengari allows lua to be used as a web-scripting language i.e. we can use lua instead of ... In JS you can print...
Read more >JsToDef - simple way to send messages from JS to Lua
Native Extension that makes possible to send messages from JavaScript to Lua in HTML5 build. Setup. You can use the JsToDef extension in...
Read more >Splash Scripts Tutorial — Splash 3.5 documentation
Splash can execute custom rendering scripts written in the Lua programming language. This allows us to use Splash as a browser automation tool...
Read more >Lua vs JavaScript | Top 10 Differences You Should Know
Lua is one of the cross-platform programming languages which is a small scripting language for designing a web application that is embedded in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Aha, you’re right. There are two issues.
<a>
elements - only buttons (<input>
elements) work. This may be fixed by https://github.com/scrapinghub/splash/pull/222, but I haven’t checked it..click()
method doesn’t allow to follow links - see e.g. http://stackoverflow.com/questions/1694595/can-i-call-jquery-click-to-follow-an-a-link-if-i-havent-bound-an-event-hand.A workaround (until Splash gets a nice library to do these tasks) is to use
window.location = document.getElementById('#link').href
:Another workaround is to use a library other than jQuery. For example, one can use CasperJS clientutils:
As an example, I’m loading CasperJS ClientUtils from github; for production it is better to find a CDN URL for autoload or serve it from your own server.
There are now scraping helpers which allow to select elements, submit forms, etc. Fixed by #490 and #531.