`execute` lua script set proxy fail
See original GitHub issueI try to set proxy in lua script with execute
,below is my code:
def get_random_proxy():
IPPOOL = eval(requests.get(
"http://192.168.89.190:8000/?types=0&count=50&country=国内").text)
random_choose = random.choice(IPPOOL)
proxy_addr = "http://" + \
str(random_choose[0]) + ":" + str(random_choose[1])
return [str(random_choose[0]),random_choose[1]]
class Exp10itSpider(scrapy.Spider):
name = "exp10it"
collected_urls = []
domain = ""
start_url = ""
a=get_random_proxy()
# here print the proxy ip and port as a list
print(a)
lua_script = """
function main(splash, args)
assert(splash:go{splash.args.url,http_method=splash.args.http_method,body=splash.args.body})
assert(splash:wait(0.5))
splash:on_request(function(request)
request:set_proxy{
host = "%s",
port = %d
}
end)
return splash:html()
end
""" % (a[0],a[1])
def start_requests(self):
urls = [
'http://httpbin.org/ip'
]
self.domain = urlparse(urls[0]).hostname
self.start_url = urls[0]
for url in urls:
yield SplashRequest(url, self.parse_get, endpoint='execute',
magic_response=True, meta={'handle_httpstatus_all': True},
args={'lua_source': self.lua_script})
below is the output,but the output shows me I didn’t set the proxy successfully,can you help me?
['101.53.101.172', 9999]
...
2017-11-20 17:49:36 [scrapy.core.engine] DEBUG: Crawled (200) <GET http://httpbin.org/ip via http://192.168.89.190:8050/execute> (referer: None)
<html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">{
"origin": "115.174.68.89"
}
</pre></body></html>
Issue Analytics
- State:
- Created 6 years ago
- Comments:11
Top Results From Across the Web
mysql-proxy not running lua script - Stack Overflow
I then select a database to use, and run a simple SELECT query on one of the tables. Based on multiple articles/tutorials I've...
Read more >Unable to get Lua Scripts to work (MySQL Proxy 0.8.1-win32 ...
I get this error message: MySQL Proxy Lua script failed to execute. Check the error log. The error log states:
Read more >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 >Tair:Usage of Lua scripts - Alibaba Cloud
Lua scripts can be used to efficiently process check-and-set ... Executes a specified script that takes parameters and returns the output.
Read more >Lua scripting - KrakenD API Gateway
Set this flag to true if you want to modify the Lua script while ... When running Lua scripts, you can place them...
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
host必须加上http://
直接给你我的中间件吧