Run Python code on a web page in a shell (utility)

If you need to put Python code in a shell that can run the code into a web page, you can use a codecamp shell. To make the work easier, I made a script that creates the html page for you.

You need:

  • a txt file with the html code
  • any python script you want to run in a web page
  • the python script to assemble the html and the python code into a web page

If you use Word press, you can include the code with these steps:

  • install Scripts n Styles plugins for WordPress
  • create a shortcut in this plugin, put the code of the web page created before in it
  • include the into the post

Check the last part of this video, to see how to put the code in wordpress.

Example

import requests import urllib.request import time from bs4 import BeautifulSoup # the site to scrape url = "https://lab24.ilsole24ore.com/coronavirus/" # access the site response = requests.get(url) # now we parse the html with BS soup = BeautifulSoup(response.text, "html.parser") h2 = soup.findAll("h2") print("Today`s data about coronavirus in Italy:") print("Confirmed: ", str(h2[0]).split("\"")[5]) print("Deaths: ", str(h2[1]).split("\"")[5]) print("Recovered: ", str(h2[2]).split("\"")[5])
Just press 'Run'.

Subscribe to the newsletter for updates
Tkinter templates

Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Claude's Games

Arkanoid
Platform 2d

1. Memory game

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Advertisement