question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lua script does not work when using dynamic proxy

See original GitHub issue

qq 20161018235532 In the first picture, I make the request with dynamic proxy and the endpoint is execute

qq 20161018235755

In the second picture, I make the request with dynamic proxy and the endpoint is render,html

And I’m pretty sure that my proxy is ok. But why lua script does not work when using dynamic proxy? Hope you can help me. @kmike

This is my code

for x in xrange(0,3):
            try:
                script = """
                function main(splash)

                    assert(splash:go(splash.args.url) )

                    splash:wait(2)



                    return splash:evaljs("document.title")
                    --return splash:evaljs([[
                        -- document.querySelector('#sf-item-list-data').innerText;
                    -- ]]);
                    -- return {html=splash:html()}

                end
                """
                agent = random.choice(agents)
                time.sleep(1)
                authHeader = self.getAuthHeader()
                headers={
                    "User-Agent":agent,
                    "Proxy-Authorization":authHeader,
                    # "Referer":"http://www.bttt99.com/",
                }
                splash_args = {
                    'wait': 1,
                    "http_method":"GET",
                    "images":0,
                    "render_all":1,
                    "headers":headers,
                    'lua_source': script,
                    "proxy":"http://101.200.153.236:8123",
                }
                yield SplashRequest(self.house_pc_index_url+"&page="+str(x+1), self.parse_result, endpoint='execute',
                                    args=splash_args,dont_filter=True)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kmikecommented, Oct 19, 2016

@playwolf719 glad to see it helped!

I think for production it makes sense to run multiple Splash containers and use a load balancer, so that if one container crashes it can be restarted without affecting clients. You can implement it yourselves, use https://github.com/TeamHG-Memex/aquarium or use hosted Splash instance which takes care of that (like Scrapinghub’s). See also: http://splash.readthedocs.io/en/stable/faq.html#how-to-run-splash-in-production

0reactions
kmikecommented, Oct 20, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Lua Scripting with Reverse Proxy - IBM
Reverse proxy supports dynamic evaluation of HTTP fallback requests using Lua scripting. Lua scripts can be used to allow, reject, or modify HTTP...
Read more >
Transformations using Lua scripting - KrakenD API Gateway
The introduction of Lua scripts in your Gateway does not require to recompile KrakenD, but unlike Go, Lua scripts are interpreted in real-time....
Read more >
Dynamic routing with nginx, lua and redis - Stack Overflow
In my lua code try to find an exact match first. After that I try to find the best matching wildcard match. It...
Read more >
5 Ways to Extend HAProxy with Lua (Guide)
Did you know that HAProxy embeds the Lua scripting language, ... You can also use the require function to load other Lua files...
Read more >
if_lua.txt - Vim
Dynamic loading lua-dynamic {only available when Vim was compiled with the ... Note: This command doesn't work when the Lua feature wasn't compiled...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found