Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 614 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run Python in a web page

#1
Well, JavaScript you know what it is. It's an interpreted language that allows us to run code directly through the web pages we visit.

Now, what if I told you that we could do exactly the same thing, but in Python?

You tell me: WITCHCRAFT!!!

And you are right. But it's totally feasible thanks to Brython. Brython is an implementation of Python 3 running in the browser, with an interface for DOM elements and events.

Here is a code snippet of what it looks like:



<html>

<head>
<script type="text/javascript" src="/path/to/brython.js"></script>
</head>

<body onload="brython()">

<script type="text/python">
from browser import document, alert

def echo(event):
alert(document["zone"].value)

document["mybutton"].bind("click", echo)
</script>

<input id="zone"><button id="mybutton">click !</button>

</body>

</html>



So you just have to load the brython.js file in the page and then call the brython() function when the page is loaded to be able to put some Python code in a script tag like you would do in JavaScript. A tutorial is available here :

[To see links please register here]

?

Magic, isn't it ?

Brython supports Python 3 syntax, including list comprehensions, generators, metaclasses, imports, etc. and many modules from the CPython distribution.

Brython has libraries for interacting with DOM elements and events, as well as existing JavaScript libraries such as jQuery, D3, Highcharts, Raphael, etc. It supports the latest HTML5/CSS3 specifications, and can use CSS frameworks like Bootstrap3, LESS, SASS, etc.

In short, it's good stuff.

By the way, if you want to see what it looks like, there's a nice page of examples with source code here:

[To see links please register here]

?

It can allow you to use existing code in web pages without having to rewrite everything in JS. And that's nice.

If you want more info about Brython, this is the place to go:

[To see links please register here]

Reply

#2
you can also use selenium to automate webhandling with python
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through