How do I display Python output on a HTML page - python

When I run the Python script it runs perfectly fine and displays the output on the shell however I want to display the output in html, how do I do it?
I already use Django but I feel like it is very tedious to display it on the html page. Do any of you know how to retrieve the output from shell to html page without being it to complicated?
I also tried REMI, and many more but I can't seem to find the perfect way to display it

Related

Cannot get my python generated chart to display on my live page

I've got some python code creating a chart from a csv file and then saving that interactive chart as an html file. I've tested the file just as a page and it works perfectly with no errors. Yet when I use PHP to display that html page in a block on my wordpress site using Elementor PHP snippets plugin, it displays fine on the editor page, but it does not display at all on the live page.
As I said, I tested the raw html code and the page displayed perfectly in my browser with no errors. I also inserted the raw HTML code into an HTML snippet and it displayed perfectly with no error on the editor page, but it also failed to display on the live page. I am using Python 3.9, PHP 7.4, XYZ PHP snippets plugin and Elementor Pro. Really stuck was hoping to find a code fix or advice on how to find a workaround. Thanks!

Can Python console output be passed via html/css for styling/app display?

The following code prints a semi-styled Python output in the console:
print("\x1b[1;34;50mKINdred Gifting\x1b[0m\n\nby\n\x1b[1;35;50mCouv's Corner\x1b[0m")
However, this is only a primitive styling compared to what I am looking for.
I am developing an app using python and the features included in the replit package:
pip install replit
and its database. I plan to switch to MySQL later on, but that is beside the point. Is it possible to style the code "print('XYX')" using html so that instead of being sent to the console as
XYZ
it will be sent to an html/css destination as a variable where it can be styled and printed on a page like a webpage, XYZ?

Any way to run web scripts from html, that browser runs automaticaly on page download?

I'm practicing in parsing web pages with python. So what I do is
ans = requests.get(link)
Then I use re to extract some information from html, that is stored in
ans.content
What I faced is that some sites use scripts, that are automatically executed in a browser, but not when I try to download a page using requests. For example, instead of getting a page with information I get something like
scripts_to_get_info.run()
in html code
Browser is installed on my computer, so as a program that I wrote, this means that, theoretically, I should have a way to run this script and to get information while running python code to parse then.
Is it possible? Any suggestion?
(idea, that this is doable, came from the fact, that when I tried to inspect page in google, I saw real html file without any trashy scripts)

python variables in html / wordpress on cpanel hosting

I have a website that I am busy working on, which is a wordpress website that is on cpanel hosting.
The customer has some python programs that output information, which he would like to display on the website. EG, he has a program that gets some data from a few other websites, and does a bunch of calculations, and then returns a total. He would like to display that total on the website.
I was told I can put the .py file onto the server, but I am not sure how to get the output onto the wordpress page, or even an html page.
The one program has about 6 different variables it outputs, and he would like to display all 6 of the figures on the website.
All the searches I am doing are showing how to output html from a python file, which is not what I want. The website exists already, and so does the python scripts. I just want to put the information from the script onto the web page.
Any help would be greatly appreciated

Scraping webpage generated by javascript

I have a problem getting javascript content into HTML to use it for scripting. I used multiple methods as phantomjs or python QT library and they all get most of the content in nicely but the problem is that there are javascript buttons inside the page like this:
Pls see screenshot here
Now when I load this page from a script these buttons won't default to any value so I am getting back 0 for all SELL/NEUTRAL/BUY values below. Is there a way to set these values when you load the page from a script?
Example page with all the values is: https://www.tradingview.com/symbols/NEBLBTC/technicals/
Any help would be greatly appreciated.
If you are trying to achieve this with scrapy or with derivation of cURL or urrlib I am afraid that you can't do this. Python has another external packages such selenium that allow you to interact with the javascript of the page, but the problem with selenium is too slow, if you want something similar to scrapy you could check how the site works (as i can see it works through ajax or websockets) and fetch the info that you want through urllib, like you would do with an API.
Please let me know if you understand me or i misunderstood your question
I used seleneum which was perfect for this job, it is indeed slow but fits my purpose. I also used the seleneum firefox plugin to generate the python script as it was very challenging to find where exactly in the code as the button I had to press.

Categories