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 templatesTwitter: @pythonprogrammi - python_pygame
Claude's Games
1. Memory gameVideos
Speech recognition gamePygame's Platform Game