Altair Offline Rendering - python-3.x

How can I create interactive charts that can be shared to others with limited internet connection?
My situation is such that I can generate and view the interactive charts I want, but due to VPN restrictions, my colleagues are not able to open the html charts that I generate. From the error message below, it seems like they are not able to render due to inability to connect to the web.
(error loading script https //cdn.jsdelivr.net/npm//vega#5 noext)

Interactive Altair/Vega-Lite charts require several javascript libraries to render the charts; in most cases these libraries are loaded from an external CDN, and so the chart will not be viewable without an internet connection.
You can get around this using the altair_saver package, which is able to save HTML charts in "inline" mode, where the required javascript libraries are embedded directly in the chart output.
For example:
import altair_saver
chart = alt.Chart(df).mark_point() #...
altair_saver.save(chart, 'chart.html', inline=True)
The resulting file can be viewed in a javascript-enabled web browser, and should work even without an internet connection.

Related

Get already opened Edge (not IE) browser window(s) and scrape contents

I used to be able to find all open IE windows via VBA and was able to access one of the already-opened page's contents in Excel with the objShell object mechanism. I didn't--and don't need--direct "control" (automation) of the browser in terms of pushing buttons, opening urls, etc.
I know automation of Edge is not possible just using VBA, but is there any ability to simply 1.) get a list of MS EDGE open windows and 2.) retrieve the elements within a given (already opened) window without resorting to downloading drivers and utilities like Selenium?
As Tim Williams had informed you there is no COM interface available for the Edge browser.
Microsoft has not provided any way to automate the Edge browser using VBA automation.
So, there is no way to fetch the already opened instance of the Edge browser and retrieve elements with the help of VBA.
I suggest you use the officially recommended way Selenium Web Driver to automate the Edge browser.
I have seen that you want to avoid the Selenium Web Driver approach but at present, this is the only way available to automate the Edge browser.
If you are having any issues with the Selenium Web Driver approach then you can inform us about it. We can try to provide suggestions for it.
Thanks for your understanding.
Please note: I'm the author of this software
You can connect to active instances of Edge with IE mode using Internet Controls for Edge: https://pomio.dk/internet-controls-for-edge/.
Internet Controls for Edge is a COM component and it exposes the same APIs as Microsoft Internet Controls (for Internet Explorer), so if you've already created some automations of Internet Explorer (using Microsoft Internet Controls), then it should be straight forward to move to Internet Controls for Edge.

Is it possible to essentially view a webpage with puppeteer?

I set up a very basic headless browser implementation with Puppeteer on a server, and the way I have it configured currently, I have the system scrape arbitrary websites based on user input. I then have the server send the html code of the page to a client using response.write. (I'm not actually deploying this as a solution to anything - it's really just a proof of concept.)
The results are mixed based on what website the system attempts to scrape from - but one thing they all have in common is that things like links and external stylesheets either work sporadically or not at all. My question is, is there a way to view the entire website, with clickable links and all, using Puppeteer? Or is this ridiculously impractical and totally hopeless?
If there is a way to approach this, some example code would be great.
Thanks!

PDF export from Java web application, with client-side visualizations

I've been converting HTML + CSS to PDF in server-side Java, e.g., Flying Saucer (http://code.google.com/p/flying-saucer/)
Now I need to look at alternative approaches with the growth in client-side visualization APIs like RaphaelJS, that should also be included in PDF exports.
Ideally, I would just have a print-friendly layout and CSS (kind of like Google maps does) and there would be some magic way that a Javascript call could silently "print" the window to a PDF file, rather than having a separate PDF generation pipeline.
Is there any such thing?
If not, what other approaches would you recommend?
For example
run Raphael server-side with node.js or Rhino, use Batik to convert SVG output to image, render PDF server-side
same thing but do some hack to grab SVG from the work that Raphael already did client-side
Do a headless-browser on the server, like wkhtmltopdf or phantomjs, to capture and execute the generated HTML/JS server side.
Any success with any of those approaches or other suggestions?
Those two options worked for me:
Client-side PNG generation with html2canvas (only works where canvas is supported)
Server-side PDF or PNG generation, with wkhtmltopdf (you might need xvfb)
Please ask if you need more details about how to use those solutions.
I set up a (very) simple test of both PhantomJS and CasperJS in order to be able to print a PDF server-side with a headless browser. It sure needs additionnal non-Java tools but I think this approach is more future-proof.
In those exemples, I am able to dynamically load a web page, let angular initialize and then interact with it with Javascript code in order to print the page as a user would have modify it in a real browser.
Here are my examples: https://github.com/fmarot/miscPOC/tree/master/angularAppOutputPDF

How to detect in advance if a browser will download a file instead of viewing it?

Sometimes when you view a file on a page on its own, the browser has some default way of viewing it, like to place it in an image or video tag, or invoke some plugin. Other times, it just downloads the file.
Sometimes this is because of headers set by the server, but lets ignore that for now. For some file types, it doesn't matter what headers were set -- the browser will try to download them regardless.
Some of the types that the browser will view are listed in navigator.mimeTypes. However, this is not authoritative. The iPad can view Microsoft Office files but it does not report this.
Is there any simple way to figure out what the browser is going to do with a file before it does it?

Unable to link directly to WMV video file

I have a wmv video hosted in SharePoint. I've created a Content Editor web part with a bit of custom content and I've placed a simple link to the video Click to view.
There is really nothing special going on here. Some users can click on the link and the video opens in their default video player. Other users see a range of different errors/prompts. Some users are prompted for their network credentials and others receive a generic "Internet Explorer cannot display the webpage.
The same problems occur if I create a generic HTML web page (outside of SharePoint) and have users try to launch the video.
I am trying to avoid embedding the video in the HTML and just have users link directly to the video itself.
Has anyone encountered this issue and do you have any suggestions for making this work?
This appears to be a combination of browser issues and file security.
People are being asked for their network credentials because the file itself is not "public"; it requires authentication to be read, or appears to do so from your description. Different browsers will display different messages when attempting to authenticate for the file.
Additionally, the default player for a browser may not be set or the browser may not allow passoff to third party programs, both of which will generate different messages for different browsers. This will always be an issue for hot-linked videos, and there's nothing you can do about it except use some guaranteed playback platform that all consuming browsers must have installed, such as Flash or Silverlight. That comes with issues all on its own, but such is the nature of the online world.

Resources