1

I'm trying to create a bot for an online game. The values for the game are stored in Javascript variables, which I can access. However, running my bot code in Javascript freezes the browser, since my code is the only thing that executes.

I'm trying to code my bot in Python, then, since it can run synchronously with the browser. How can I pass the Javascript variables to a client-side Python program?

Jared Nielsen
  • 3,669
  • 9
  • 25
  • 36
  • Have you tried writing python code to load the end point with the values or parse the HTML file to extract the values? – metatoaster Apr 07 '14 at 04:32
  • @metatoaster The problem is that the Javascript values change multiple times a second, so I need an efficient way to transfer those mutable values to my running Python program. – Jared Nielsen Apr 07 '14 at 05:04
  • 1
    Then it sounds like you need python to run javascript, i.e. build an engine, but that's probably not what you want to do. Try to figure out how to run javascript asynchronously in your browser. See: http://stackoverflow.com/questions/9516900/how-can-i-create-an-asynchronous-function-on-javascript?rq=1 – metatoaster Apr 07 '14 at 05:14

1 Answers1

1

I'm trying to code my bot in Python, then, since it can run synchronously with the browser. How can I pass the JavaScript variables to a client-side Python program?...

You can pass the JavaScript variables only with query string. I create the server in CherryPy (CherryPy is an object-oriented web application framework using the Python ) and the client function with file HTML.

Repeat: The data can be passed only by query string because the Server works statically and the Client works dynamically. This is a stupid sentence but so function a general Client/Server. The server receive a call or message one times and offers the service and response. I also can wrong....This is a my opinion.

Exists Mako Templates where you can include the pages HTML (helpful for build the structure of the site) or pass variable from Server to Client.

I not know nothing programs or languages that you can pass the JavaScript variable to Server (and I try with Mako Templates but not function).

Mirko Cianfarani
  • 2,023
  • 1
  • 23
  • 39