Introduction

Installation

Frequently asked questions

Syntax, keywords and built-in functions

Standard distribution

import implementation

Browser interface

Brython-specific built-in modules

Working with Brython

Brython for Firefox OS

Cookbook

 

Problem

Get the content of an element of a web page

Solution

Show text

from browser import alert, document

# document['zone'] is the colored cell
alert(document['zone'].text)

Show HTML code

from browser import alert, document
alert(document['zone'].html)

Show value in entry field

from browser import alert, document
# document['entry'] is the input field
alert(document['entry'].value)

Cell content

Each element in the page has an attribute text, a string with the text shown in the element

It also has an attribute html, a string with the HTML code inside the element

Input fields have an attribute value, a string with the current field value

alert() is a function defined in module browser that shows its argument in a popup window