I have a website where the user goes to another website, copies the content, pastes into a text box, and clicks submit. My PHP script parses the content and imports a table into my MySQL database. I am looking to automate this. I know the PHP file_get_contents command will get the source code of a website, but I am looking to get the content as it is displayed on a browser.
The script does not have to be in PHP - I am open to anything. Any suggestions very welcome!
Thanks!
Related
I'm trying to create a 'download' page for my website. I'm using a url like this: http://example.com/download?file=21. The actual location of the file on the server is stored in a database along with the file ID. I would like the download page to display the name of the file that is being downloaded along with some other HTML. I'm having trouble figuring out how to both download a file and display output on the same PHP page.
All the advice I've seen for actually downloading a file with PHP requires changing the headers. Do I need to display the download page and then download the file with something like AJAX?
I would do it without ajax.
I would create a script to show the file with other html info http://example.com/file?id=21 and if the download param is set ( http://example.com/file?id=21&download=1 ) that script only prints the headers and sends the file.
Then, in http://example.com/file?id=21 I would create an empty iframe (in the code or dynamically with javascript) and then when a user wants to download the file you just have to set the url of that iframe to http://example.com/file?id=21&download=1 and the file will start to download. No need of ajax or reloading the website, only javascript to set the iframe url at the moment the user wants to download the file.
It's not the only way but I think it's a good one.
i have a problem in php..
i already stored video (arrow.S03E18.mp4) to my directory ex:C:/xampp/htdocs/telorbanget/media/ then i already write the path to mysql ex:http://localhost/telorbanget/media/arrow.S03E18.mp4
so, i have url in mysql now ex:http://localhost/telorbanget/media/arrow.S03E8.mp4
i want to put the url to my browser address bar so i can watch streaming this video through browser
can you guys help me to solve this problem?
thanks for answering..
Instead of showing it in the browser, you can actually embed the video in the same html page wherever you are trying to show this video.
Other way to do it is to write a php redirect whenever user clicks on another page (<a> tag).
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.
Chrome allows users to hit Ctrl + P and choose 'Save to PDF'.
Is it possible to have this function through an html button?
I want the user to just hit a button and go directly to the Save as PDF prompt ( where the file name is set by PHP and not automatically by Chrome ). So the user basically just hits the button and clicks on Save on the prompt window.
Is this possible?
Can I skip the previous steps?
Nope, it's not possible.
But, you can give the user the choice to download a HTML file output as a PDF file. There are a few libraries around, Prince is the best but expensive, so check out DOMPDF.
By the time your user can hit ctrl+P in the browse, the PHP process that generated the page (on server) is already closed.
Besides the fact that PHP exerts no direct control over browsers. It just sends them information in the form of HTML/CSS and important in this case JavaScript.
With JavaScript you could trigger the normal print behaviour of the browser but you would have no control over it.
Another approach could be to generate the PDF on server and send it as a file to the browser. In which case the browser will either ask the user if he wants to open it or it will ask the user if he wants to download it.
I've personally used fPDF to customise the PDF invoices of various open source e-commerce software. Like for example PrestaShop.
All you really need to do is download the library from (fPDF](http://www.fpdf.org/), but seeing it in action and being able to change/adapt a working version might help you so you could look for the PDF invoice in a fresh the PrestaShop install inside the folder classes the file name is PDF.php .
I lost several hours trying to make conversion to pdf on the server with no luck because my view contains some jquery functions that do the main rendering. I thought of providing a button to save as pdf using the browser but then opted to using javascript on the client side to do the rendering to pdf. This may not be the optimal solution in certain cases but looked the most sensible one in my case.
there are many libraries I just started using html2pdf.js and it is working fine so far.
How to load javascript contents using php. Suppose when php saves a file using, file get contents and file put contents, JavaScript contents like Google current ads is never loaded but the google adsense codes are loaded.
Can php "run" the JavaScript code on a saved page in order to save the dynamic content that the code generates?
Already got the answer is NO.
Is there any way or no Way?
You are asking whether or not PHP can "run" the JavaScript code on a saved page in order to save the dynamic content that the code generates. The answer is no, it cannot. Or at least, not without building your own JavaScript interpreter.