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

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!

Related

Web scraping (Shopify Blog Post) Not getting the HTML content using Python Selenium

I am trying to web scrape Shopify Blog, to send text from python script which will upload to the blog. I have successfully log into the desired page of the Shopify Blog but when I tried to access the text field (using class, xpath) Python script didn't show at all. But this will exist in the actual HTML page as shown below.
Actual page
I am getting the content of half of the page (shown in green Box of Figure 2). While the content of red box is absent from the extracted python selenium driver Object/variable.
Figure 2 Blog post
Looking forward to your help.
I tried Selenium Python Library to extract the page contents.

How do I display Python output on a HTML page

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

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

Inputing an MPLD3 graph into Wordpress

I'm having trouble getting my mpld3 plot to show up in my Wordpress page. I make my plot, then use mpld3.save_html() to get an html file that contains my figure. However, when I paste this code into my Wordpress page (using the Text editor, not the visual editor) nothing happens. I paste both the script and div tags. I know my javascript is working because I can write alert('Hello'); inside script tags, which works fine. I've also tried installing the "Insert Javascript & CSS" plugin, which also did not work.
Is there some way to embed these graphs into Wordpress, and if not, how does one embed interactive charts in a Wordpress post?
I suspect that the d3.js and mpld3.js were not found, which would explain why you don't see the chart.
There is a d3_url and mpld3_url that you may want to provide and set to the url of a CDN where the files are available for example See https://mpld3.github.io/modules/API.html#mpld3.fig_to_html
Even after setting that properly you may have problems as this is not the recommended way to use javascript within wordpress. You can also try an embed with stricter separation from wordpress: see http://www.datamaplab.com/posts/embedding-javascript-visualization-wordpress/ for reference.

Categories