File not getting read using file_get_html - php

I am using curl to store webpage in txt file and then reading the file to parse its content.
For some website its running fine but for some websites it is(file_get_html) returning null.
I have checked that txt file is generated with data but it is unable read the content.
For this website when i use direct link in file_get_html at that time also it returns null.
I have added user agent but not working.
Finally i removed all the content from file except one div tag at that time it read the content.
Kindly suggest why is it happening like this?

Related

Output HTML and Download a File with PHP

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.

Script to copy website content - not source code

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!

PHP send data to parent window without using javascript

I am using FPDF to create a pdf document in an iFrame... During the pdf creation the script communicates and gets a lot of data from the server, and then I would like to display a progress bar.. That is why I have put the php generator in an iFrame.. then my plan was that the php script could send the looped data to the parent window..
e.g. every time a loop is made it says $count++;, then I know how many loops it has gone through, and I already know that it is going to limit the rows to the first 200 rows.. Then I would like to display the looped data in the parent widow like so: $count of §goal has been generated successfully!.. At the moment I am using jQuery, where I ask the php to echo some jQuery script every time a loop is made to display the results like so window.parent.count($count, $goal);.. Count in the parent winodw and it actually works well until the PDF has to be shown.. then I get an error message that tells me that the script is unable to display the PDF because the page already has outputted data..
Does anybody know how to make the PHP to send the data to the parent window, so I prevet the using of echo?
Sorry for my bad english.. if wished I can try to upload my script later for you to see...
I do it a bit differently...
I also wrote an application in which the PDF generator needs to fetch a rather large amount of data, so the generation takes a few seconds.
I use jQuery to fetch a php-page in the background. During this download, the screen turns gray and displays a classic "please wait"-circle. The only output that the php-file generates is an "OK" echo, together with a file link, when the generation has been completed. Instead of displaying the file inline, I save the PDF in a folder ($pdf->Output('filename.pdf','S')) and offer it as a download using the provided link and the jQuery-callback.
I hope you understand what I mean. Maybe this thought will help you a bit further.
EDIT: Don't know if this will work, but I just thought of it...
You could save the file and output the filename. Using jQuery, you could then refresh the contents of the iframe to fetch a page in which you display the already saved PDF inline...

How to load javascript contents using php?

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.

Remote uploading images - file_get_contents(); to help me?

I'm wanting to create a website that allows an user to put a link in a field and once the user submits the form, the "image" link added to the field will be remote uploaded to my server (to the path I specified in my server).
A friend of mine did this once, and he told me that he used the file_get_contents() function to get this working, but I cannot figure out how I'd do it.
Any help would be appreciated.
Thanks.
file_get_contents() will read file contents into a variable.
if you need to copy file to your server, use copy() instead.
copy($_POST['link'],basename($_POST['link']));

Categories