If you look at evernote or use their web clipper browser addon, it can save a webpage completely with all styles and images of page clipped. So for example if I save this very page with it, it will be saved as is.
Does any one have an idea of how evernote does it? I want to do it with either PHP or JavaScript but am not sure how to save a webpage with all styles and images. I know about Internet Explorer's mht format but that's not what evernote does.
So basically it would be great if one can save a webpage with all styles and images (excluding dynamic content such as JS) in single file and be able to open it in any major browser ? Any pointer to such script would also be helpful.
I have also noticed similar thing in Gmail, when you copy any part of page and paste that in Gmail Compose, it renders it as it was or same happens in MS Word too.
Thanks for your help and hints :)
Replace linked stylesheets with style blocks containing the CSS copied from the linked stylesheets. Replace image sources with data URLs.
Or just shell out a call to wget -mk and mirror the site:
<?php
system('wget -mk http://foo.com/bar');
?>
You could do file_get_contents() and then go and recursively download whatever scripts/images you need.
Related
Is it possible to put PHP code into raw images?
For example:
http://gifsec.com/wp-content/uploads/GIF/2014/05/GIF-When-white-guys-dance.gif
If you go to that url you'll just see the raw image on a white page. Is it possible to somehow put code into this raw page? For example, you may want to put Google analytics tracking into raw image files so you can track people on reddit sharing raw files.
Not that I know of, what you may want to consider is having people share the link to that file so they can download it and then put code into the page that link redirects to that tracks or counts visitors. Tracking the visitor is harder and leads into ethical issues, so I would just set up google analytics and put their code into that page.
No,
http://gifsec.com/wp-content/uploads/GIF/2014/05/GIF-When-white-guys-dance.gif
is a resource on your server. that URL simply directs the browser to where the image is stored on the server.
to achieve what you want. simply create a page and include the image into
http://gifsec.com/GIF-When-white-guys-dance
<img src=''> on this page you can then add your Google analytic code.
Images are transferred from server to browser with binary encoding. this is why it will not work how you are thinking
You can hide anything you want in an image file. This is called steganography. The problem is that the code won't be executed unless it's uploaded to a server that is specifically set up to extract and run it.
It's not silly, just difficult. What you would have to do is use a PHP script to process it back. As such, your dance.gif would become dance.php and you would link to that. It will add some overhead to your server to do this so just be aware, however, this would allow you to track it via PHP. You could then import that data into Google Analytics at a later date.
Here's some pseudo code (we'll call this dance.php)
<?php
//Insert some tracking here, like a Database INSERT statement
$img = imagecreatefromgif('/path/to/dance.gif');
header('Content-Type: image/gif');
imagegif($image);
imagedestroy($image);
Then in your HTML
<img src="dance.php">
What you need is called pixel tracking also called web bug.
Take a look at this answer:
https://stackoverflow.com/a/13079838/797495
I am showing a list of files on a webpage. Files may be of any type like pdf,doc,excel,txt etc.
What i want is when some one click on an item of the list then that file should be displayed in another tab. I dont want to download the file. I just want them to be visible so that user can read it.
I try this using php for pdf files i am able to get the plain content of the file but i want a viewer type of thing.
Can i achieve this?
If yes can i achieve this in php?
If yes then how?
Thanks and Regards
Sumit Rathore
downloading or viewing any file in browser depends on browser setting.
for example in firefox in Options - > Applications Tab you can change state of reading a file that can be downloading or viewing.
now, for display a file to visitor best solution is creating a special php or flash app.
Good Luck.
see http://view.samurajdata.se/
<html>
<body>
<embed src="www.dedoimedo.com-apache-web-server-lm.pdf">
</body>
</html>
This code is working in google chrome but not in other browsers.
I have a website textscloud.com In this website i make the image with the PHP GD library. Here is a link to a demo:
In this page i allow the user to download the image on which text will pe printed. download link is like
This download.php file has a header for making the image with PHP GD Library and download the file like this
header("Content-type: image/png");
But google didn't crawl these images. Does anyone know the solution? I can't store these image in server.
You don't mention how you are feeding the beast, so I suggest you start by providing google a site map via their webmaster toolkit. You can specifically list the images that you want crawled. Google provides good help articles to get you going.
Google can't index images that are not stored permanently, I'm quite sure it can't even index images without context (i.e. which are not part of a describing/linking page).
You can try to:
Send a cache header to allow caching of the image.
Rewrite the actual url to someting like: http://textscloud.com/get_img/download/VkZaU1FtUXdNVVZWVkZKT1ZWUXdPUT09.png (should match your filename header)
How could I use imagegrabscreen to get a thumbnail image and a full size image of a specific website.
I was thinking that I could have an array that I feed the wanted uri's into but I am a bit stuck on how I would set the wxh of the image I need to grab. I also think that I would need a thumbnail class and a fullimage class and call them when required.
Any better Ideas?
Keep in mind that imagaegrabscreen is Windows-only. If you have multiple displays set up, this function will only grab the primary display. Also, for this to work, your Apache service must be set to Allow service to interact with desktop otherwise you will just get a blank image.
This discussion covers the use of imagegrabscreen pretty well: Getting imagegrabscreen to work
There are a lot of other discussions about saving webpages as images, too - here are a few:
Website screenshots
Web Page Screenshots with PHP?
How can I generate a screenshot of a webpage using a server-side script?
PHP: How to capture browser window screen with php?
What is the best way to create a web page thumbnail?
Screenshot of current page using PHP
shell tool which renders web site including javascript
In any languages, Can I capture a webpage and save it image file? (no install, no activeX)
I am looking for some help in downloading pics from a website. Here is the problem detail.
URL is basvandenbroek dot com,
suppose when we visit the following page http://www.basvandenbroek.com/nl/product/27341/704/snaarinstrumenten/boston/snarenset_elektrisch.html
we have a thumbnail pic here which when click bring its larger version. I would like to capture the larger image using a php script and download it onto my pc.
Problem is when we inspect the HTML we see the following code for images
../../../../../../../jpg/27000/27341.jpg
../../../../../../../jpg/cache/27000/220_220_27341.jpg
Based on the above code i assume that if i append website address at the start of the
jpg/27000/27341.jpg I could access the pic but its not working it that.
I believe URL is hidden or I might not understanding things properly. I am new to PHP and Scripting and I would like somebody to help me through it situation.
Thank you
For the website you mentioned, if the thumbnail is
http://www.basvandenbroek.com/jpg/cache/27000/220_220_27341.jpg
then the
http://www.basvandenbroek.com/jpg/27000/27341.jpg
So the thumbnail is basically the dimensions (220 x 220) added as a prefix to the original in a different folder. Also, there is nothing like hidden URL. Any link that is valid on a web-page is sure to appear in the source of the html. In chrome and firefox, atleat, you can find this link by right-clicking the link and copying the link address.
In your case you can find the thumbnail's url by right-clicking the thumbnail and the original's url by right-clicking it.
However, if you want to do this automatically using PHP, you will have to write code that can parse the html for the page to determine the urls.
In your example, here would be the larger image:
http://www.basvandenbroek.com/jpg/27000/27341.jpg
The smaller image is at:
http://www.basvandenbroek.com/jpg/cache/27000/220_220_27341.jpg
This means you would need to scrape out the first two underscored parts of the name (220_220) using string manipulation. You would also want to string replace "cache/" with an empty string.
relative urls are relative to the url of the containing document. so if the document you're scraping is located at http://example.com/foo/bar/baz/doc.html, and the image is referenced as
../../omg/wtf/lol/cat.jpeg, its full url is http://example.com/foo/bar/baz/../../omg/wtf/lol/cat.jpeg, or http://example.com/foo/omg/wtf/lol/cat.jpeg.
btw, this has nothing to do with PHP or scripting in general, and is instead firmly a HTTP thing. and there are no "hidden" URLs in HTTP, that would be a contradiction.
edit: your comment makes it look like the problem is with the Referer header or session id sent (or not) in your request.