Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Webmaster Zone > Web Development
Register

Reply
 
LinkBack Thread Tools
Old 24.10.2003, 15:27   #1
Младенец
 
di0phantus's Avatar
 
Join Date: 05 2002
Location: Yerevan, RA
Posts: 58
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default Открыть Url ресурс через прокси...

Вот небольшой скриптик, который
скачает парочко манга прелестей
PHP Code:
<?PHP

 $folder 
"hentai_01";
    
 
$url_prefix "http://www.hentai.ag/hentaibilder/$folder/bilder_gross/";

@
mkdir("hentai");


for (
$i 2$i<3$i++) {
    
$file_name = ($i<10?"0":"") . "$i.jpeg";

    echo 
"reading file $file_name ...";
    if (!(
$content = @file_get_contents($url_prefix.$file_name))) {
        echo 
"\nproblems reading file $url_prefix$file_name\n";
        continue;
    }

    
    echo 
"OK\nWriting to file...\n";
    
$handle fopen("./hentai/".$file_name"w");
    
fwrite($handle$content);
    
fclose($handle);
    echo 
"DONE\n\n";
}
     

?>
однако есть небольшая проблема...

никак не могу заставить скачать все это через прокси сервер..
пробывал так..
PHP Code:
<?PHP

 $folder 
"hentai_01";
    
 
$url_prefix "http://www.hentai.ag/hentaibilder/$folder/bilder_gross/";
 
$proxy_server "http://our-proxy:8888/";

@
mkdir("hentai");


for (
$i 2$i<3$i++) {
    
$file_name = ($i<10?"0":"") . "$i.jpeg";

    echo 
"reading file $file_name ...";
    if (!(
$content = @file_get_contents($proxy_server.$url_prefix.$file_name))) {
        echo 
"\nproblems reading file $proxy_server$url_prefix$file_name\n";
        continue;
    }

    
    echo 
"OK\nWriting to file...\n";
    
$handle fopen("./hentai/".$file_name"w");
    
fwrite($handle$content);
    
fclose($handle);
    echo 
"DONE\n\n";
}
?>
в прошлий раз целых 13мб скачал что недопустимо...

может кто то знает как можно это сделать?
заране всем спасибо!
Reply With Quote
Old 24.10.2003, 18:43   #2
¡no pasaran!
 
dolphin's Avatar
 
Join Date: 03 2002
Location: localhost
Age: 35
Posts: 540
Downloads: 0
Uploads: 0
Reputation: 13 | 4
Default

Нифига не понял вопроса [(c) windovz ]

при чем тут 13мб ?
Reply With Quote
Old 27.10.2003, 14:35   #3
Младенец
 
di0phantus's Avatar
 
Join Date: 05 2002
Location: Yerevan, RA
Posts: 58
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

erku xosqov...
asenq grum em senc ban

$cont = file_get_contents("http://ex.com/image.jpg");

es depqum dirrect kkpni u kqashi (ete iharke ka dirrect connection),
isk ete uzum em cherez proxy server?

mi dzevov pordzel em, indz tvum er vor piti ashxati bayc vrodi chashxatec...
asenq togh proxy-in lini proxy:80
de qani vor proxy-in galis zapros tipa
GET /http://ex.com/image.jpg u eli mi erku param tipa HTTP 1.0 ,....

pordzel ei senc grel

$cont = file_get_contents("http://proxy:80/http://ex.com/image.jpg");
__________________
Все не так уж важно ...
Reply With Quote
Old 27.10.2003, 18:56   #4
¡no pasaran!
 
dolphin's Avatar
 
Join Date: 03 2002
Location: localhost
Age: 35
Posts: 540
Downloads: 0
Uploads: 0
Reputation: 13 | 4
Lightbulb

ты не учитываешь, что будет послан такой запрос:

GET /http://ex.com/image.jpg HTTP/1.0

а не

GET http://ex.com/image.jpg HTTP/1.0

... смотри в сторону fsockopen() и спецификации HTTP
Reply With Quote
Old 29.10.2003, 09:50   #5
Moderator
 
Join Date: 03 2002
Location: Russia
Posts: 123
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

di0phantus
RTFM - http://www.php.net/manual/en/function.fopen.php

Code:
$f = urldecode("http://www.test.com/someurl/somepage.php");
$data = fsockopen("proxy.dom", 8080, &$errno, &$errstr);
if( !$data )
{
	echo "proxy not available !";
	fclose($resultfile);
	exit();
}
else
{
	fputs($data,"GET $f \r\n");
	while (!feof($data))
	{
		$fdata = fgets($data,1000);
	}
}
Reply With Quote
Old 29.10.2003, 12:13   #6
Младенец
 
di0phantus's Avatar
 
Join Date: 05 2002
Location: Yerevan, RA
Posts: 58
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

dolphin:

kazhetsya forma zaprosa GET-a (lishnyaya '/') ne vliyaet na rezul'tat, ya probival na localhost-e sdelat' zapros cherez svoj proxy host, (v JBuilder8 est' takoj tool, TCP Monitor on zhe imeet rezhim proxy). kogda ya poprobival cherez etot proxy, to vse proshlo normal'no, url resource tipa http://localhost:8080/http://localhost/image.jpg sdownloadilsya.
trudno skazat' kak povedut sebya drugie normal'nie serveri, mozhet i proignoriruyut a mozhet i net...
a togda do etogo ne doxodilo, okazivaetsya tut u nas -
proxy authorization required!
a u menya pered funkciej stoyala @
$data = @file_get_contents ... vot i prebival ya v neznanii


po pravde govorya ya nadeyalsya chto standartnij wrapper http imeet dopolnitel'nie opcii, tipa postavil bi chto-to poxojoe
$GLOBALS['http.proxy.server'] = 'proxy';
$GLOBALS['http.proxy.port'] = '8080';
$GLOBALS['http.proxy.user'] = 'me';
...
i vse poshlo bi kak po maslu!

nado bi esche poiskat',
ili mozhno pozaimstvovat' bolee gibkij http wrapper u drugix kto uzhe reshil etu problemu,
a v krajnem sluchae napisat'... kak eto predlogaet hayk. spasibo konechno, no etot put' nemnogo dlinnovat, i on stal esche dlinee esli uchitovat' chto mne nado eshe provodit' proxy authorization.. i vse v ruchnuyu.

ya esche poishu, esli naydu chto to stoieshee to dam znat', vse taki ne sovsem uzh bespoleznij vopros
Reply With Quote
Old 29.10.2003, 13:09   #7
Moderator
 
Join Date: 03 2002
Location: Russia
Posts: 123
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

Смотри это:
HTTP_Request - Provides an easy way to perform HTTP requests. Supports GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy, Proxy Authentication, SSL, file uploads etc.
HTTP protocol client - HTTP client to access Web resources.
Advanced HTTP Client - GET, HEAD, POST methods with a lot of features.
Reply With Quote
Old 29.10.2003, 14:30   #8
Младенец
 
di0phantus's Avatar
 
Join Date: 05 2002
Location: Yerevan, RA
Posts: 58
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Thumbs up

spasibo, otlichnie site-i :agree:
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 06:12.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.