Page 1 of 1

copy html to txt

Posted: Sun Sep 30, 2007 12:54 pm
by ehssan2
i want to use a code like this to copy the html to txt.

Code: Select all

if (isset($_POST['Submit'])){
$url=$_POST['ads'];


$newfile = 'tmp.txt';

if (!copy($url, $newfile)) {
    echo "failed to copy $file...\n";
}else{
echo " Copy Shod";
}


}
this code works fine but if my url has internal server error (500) it does not copy what i see on my brawser.,
i want this code to work even if the url has error 500.
can you please help me, or suggest me different command instead of copy.
thanks

Posted: Sun Sep 30, 2007 1:11 pm
by feyd
This thread is extremely similar to your last thread. :?

Posted: Sun Sep 30, 2007 2:30 pm
by ehssan2
yes i know but i didnt get any answer,
please help me,.
do i have to install any extensions?????

Posted: Sun Sep 30, 2007 2:47 pm
by superdezign
What *does* it copy?

Posted: Sun Sep 30, 2007 2:51 pm
by ehssan2
this code copies any url ro txt
but it does not copy the errors , like sql errors ,
for example the url of http://www.yahoo.com works fine
but a url like http://www.webna.ir/category/?id=' which contains sql error
i need this sql error to be copied in to txt file.

Posted: Sun Sep 30, 2007 3:08 pm
by superdezign
I don't see the SQL error on that page (unless it's just not in English). PHP can only copy what is served to it via the server. If nothing is printed, nothing is copied.

Posted: Sun Sep 30, 2007 3:56 pm
by ehssan2
superdezign wrote:I don't see the SQL error on that page (unless it's just not in English). PHP can only copy what is served to it via the server. If nothing is printed, nothing is copied.
lets say this one
http://www.gpspassion.com/fr/news.asp?id='
or
http://www.yaranevesal.ir/newsdetail.asp?id='
all of these site have sql injection problems,
i would like this script to gather these kind of informations.
i need to collect Mysql or MS-SQL OR any other Db's error.

Posted: Sun Sep 30, 2007 4:38 pm
by superdezign
I didn't see any SQL error on the first page, but I do see one on the second page. Do you not get that data using copy()?

Posted: Sun Sep 30, 2007 4:42 pm
by ehssan2
no i need to copy these errors to txt file using this script.
this is the link correct one http://www.gpspassion.com/fr/news.asp?id='
i need to get these kind of errors.
but as you know the page Status is 500 (internal server error)
and it does not copy .
waiting for your kind advise superdezin

Posted: Sun Sep 30, 2007 5:10 pm
by superdezign
Ohh, I see, now. The single quote wasn't being parsed as a part of the URL for any of those links you've posted.

Maybe you should try using file_get_contents() or cURL.

Posted: Mon Oct 01, 2007 11:31 am
by ehssan2
by using get contents it didnt work
Warning: file_get_contents(http://www.rahafestival.ir/shownews.asp?id=')
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in C:\www\a\1111.php on line 15

please some one ....and other clue

Posted: Mon Oct 01, 2007 2:36 pm
by feyd
The error specifically states that their server refused to respond.