Jared Nielsen
Jared Nielsen

Reputation: 3897

Reading Javascript Variable in Python

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?

Upvotes: 1

Views: 736

Answers (1)

Mirko Cianfarani
Mirko Cianfarani

Reputation: 2103

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).

Upvotes: 1

Related Questions