I want to download some images with PhantomJS but I have a little problem.
My code is this:
page.open( url, function ( status ) {
page.render( "test.jpg" );
phantom.exit();
});
The problem is that the URL redirects to the home page of site.
How can I disable the URL redirect and save the image?
The URL is something like: http://some_url/00.jpg.
I want to download this (and others) image from this site, but with the redirect is impossible for me save the image.
I have not found anything on the internet that might solve my problem.
Anyone can help me?
Related
The following code should work with plain html
Open pdf
It also works with Blazor (WebAssembly) but only from localhost. A new tab is opened with address https://localhost:[...]/pdf/foo.pdf. In production, the browser tries to open https://[...]/pdf/foo.pdf and I get the error
Sorry, there's nothing at this address.
Is there a solution for Blazor?
Edit 2
I deleted my first edit, because with the following new information, I think it is not relevant anymore.
Since I thought, it was a problem with deploying pdfs on netlify, I asked in their forum: https://answers.netlify.com/t/how-can-i-deploy-a-pdf/54897. (Sorry, the short links syntax [][] does not seem to work in edits.) I created a demo page (https://beautiful-snickerdoodle-bb5389.netlify.app/) and found out, it is not working on my PC and several laptops, but on my smartphone. A user in the netlify forum was able to display the pdf in Chrome but not Safari. So, I think, it is not a problem with netlify but there is something wrong with my page. Any help is greatly appreciated.
How you serve a download is your choice, how it is handled is the users choice,
there are two recommended methods,
offer <a href="absolute fab.pdf" download>download this fab pdf, I promise its safe to run</a>
If you cant see anything in this blank iFrame your browsers exploit security is perfect.
Your path to "pdf/foo.pdf" denotes that there is a pdf folder in wwwroot folder of your website, make sure this folder also exists in your prod environment and has pdf file you are trying to open, also make sure this folder has read/write rights for IIS_IUSRS
I finally found a solution.
What works in "normal" HTML, does not work in Blazor, because the service-worker routes unknown routes to index.html. See onFetch() method of service-worker.published.js:
const shouldServeIndexHtml = event.request.mode === 'navigate';
const request = shouldServeIndexHtml ? 'index.html' : event.request;
When I click the link Open pdf, the shouldServeIndexHtml is true.
To avoid this, I changed above code to
const shouldServeIndexHtml = event.request.mode === 'navigate'
&& !event.request.url.includes('/pdf/');
const request = shouldServeIndexHtml ? 'index.html' : event.request;
This works, because my pdfs are in a subfolder "pdf" under wwwroot. Since the url includes "/pdf/", the shouldServeIndexHtml becomes false and the pdf is displayed. Please find more information here.
I have a Gatsby site. If I hit a url that doesn't exist, Gatsby serves up a 404 page, however it doesn't change the URL.
I am testing this site using Cypress. Cypress's recommended way of testing navigation within a site is the use of location, however in this instance, checking the pathname of the page that was navigated to is not reliable, as if the page doesn't exist, it will still have the same pathname as if it did. For example if I get Cypress to cy.click() a link with an href of /incorrect-url/, and test its pathname, I would get a passing test, even though the page that loaded was the 404 page, not the page I was expecting.
I know I could test that elements I am expecting are present on the page I've navigated to, but I'd prefer a reliable way to know if the page 404d (Gatsby returns the page with a 404 status code).
To summarise:
checking the Location / pathname is not a reliable way of testing that a specific page has loaded
I don't want to check for elements on the page as a way of verifying
Surely there is way of verifying that the page loaded without a 404 status code.
How can I reliably check that the page navigated to was not the 404 page.
I know the question was asked 2 months ago, so hopefully you've already found a way to validate the status, but as a future reference, you can do a request to your link's href attribute. You will then have access to the status code.
cy.get(SELECTOR FOR YOUR LINK).then((link) => cy.request(link.prop('href')).its('status').should('eq', 200));
I've uploaded a new static blog to GitHub Pages using Ghost and Buster.
Github Repo: https://github.com/paddy420Smokers/cannalogie
I've added the code below to force all pages to use https:// , on the Frontpage and Category Pages its working fine, but on Posts only https:// is there but it's not fully secured.
<script>
var host = "cannalogie.net";
if ((host ==window.location.host) && (window.location.protocol != "https:"))
window.location.protocol = "https";
</script>
Does anyone know how to fully secure all pages and posts?
Looking at the developer tools, it looks like you're loading something that over http while the rest of your page is loaded over https. That causes the whole page to be considered insecure and not show the lock symbol, even if the url shows https.
It looks like you're loading a .gif over http. If you change the url to load it over https, the error should go away and the lock should appear.
Can anyone please help me with is question here. I want to set a CMS page as homepage in prestashop 1.7 and still able to keep the old default Prestashop homepage as my Shop button link in menu still?
Best way is to make a redirection, because on the Prestashop backend you cannot do that easely and it could harm your website. You can also build your own Html and integrate it on the homepage via a module.
But best seems to be with a redirection :
Your server uses apache, just add this line to the .htaccess :
Redirect 301 /retiredpage.html /newpage.html
Your server uses nginx, add this line to your configuration : rewrite ^/retiredpage.html$ /newpage.html permanent;
You don't know and you don't want that ? Just use a redirection module, there are many on Prestashop Addons.
On the index.php page at the root of the site, replace the code with that:
require(dirname(__FILE__).'/config/config.inc.php');
if(Tools::getValue('home')) {
Dispatcher::getInstance()->dispatch();
} else {
$link = new Link();
Tools::redirect($link->getCMSLink(ID_PAGE_CMS));
}
Then if you go on the homepage you will be redirected to the CMS page for which you have indicated the link, to go via the menu on the real home page, add? Home at the end of the url of your website www.yourwebsite.tld? home
on a website I display links to PDF files.
When the first time call for a file arrives, the request gets redirected to a php-script that generates and returns the file. Additionally, it saves the file to the linked location so next time it will be directly availibe. I send the pdf mime type to make the browser open a download dialog instead of redirecting.
Due to reasony beyond my control, one out of 20 files cannot be generated.
How to respond?
Error 404 or 500 would direct the browser to an error page, while sending a mime-type would let the user download an empty / defect pdf file. Is there an established best practise? How to let the user know that a file link is broken, yet keep him on the site without redirect?
I had the same problem and solved it as follows:
If you have link to file, for example:
<a download href="/files/document.pdf">Click to download</a>
And if you don't want the browser redirect to blank/error page if the file doesn't exist, just reply with 204 without any content.
Nothing will happen, the user will stay where he is without redirection.
In php it would look something like this:
if (!readfile("/files/document.pdf") {
http_response_code(204);
die();
}