copy html to txt

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ehssan2
Forum Newbie
Posts: 7
Joined: Sat Sep 29, 2007 12:32 pm

copy html to txt

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This thread is extremely similar to your last thread. :?
ehssan2
Forum Newbie
Posts: 7
Joined: Sat Sep 29, 2007 12:32 pm

Post by ehssan2 »

yes i know but i didnt get any answer,
please help me,.
do i have to install any extensions?????
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

What *does* it copy?
ehssan2
Forum Newbie
Posts: 7
Joined: Sat Sep 29, 2007 12:32 pm

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
ehssan2
Forum Newbie
Posts: 7
Joined: Sat Sep 29, 2007 12:32 pm

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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()?
ehssan2
Forum Newbie
Posts: 7
Joined: Sat Sep 29, 2007 12:32 pm

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
ehssan2
Forum Newbie
Posts: 7
Joined: Sat Sep 29, 2007 12:32 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The error specifically states that their server refused to respond.
Post Reply