Python fpassthru?

0 Cevap php

Python bir dosya indirmek için bir örnek kod bulmak için çalışıyorum. Kesin olmak gerekirse, Python için bir php dönüştürmek çalışıyorum.

Benim php Numuneler kodu:

$http_request = "POST $path HTTP/1.0\r\n";
$http_request .= "Host: $host\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
$http_request .= "Content-Length: " . strlen($data) . "\r\n";
$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
$http_request .= "\r\n";
$http_request .= $data;

$response = '';
if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
die ('Could not open socket');
}

fwrite($fs, $http_request);

$headerpassed = false;
while ($headerpassed == false) {
$line = fgets( $fs);
list($tag, $value) = explode(": ", $line, 2);


if (stristr($tag, 'Location')) {
$target_url = trim($value);
header("Location: http://127.0.0.1/umsp/plugins/".basename(__file__)."?".$url_data_string."\r\ n");
continue;
}


if (trim($line) == "") {
$headerpassed = true;
header('Content-Type: video/avi');
}
header($line);
}


set_time_limit(0);
fpassthru($fs);


fclose($fs);

Ben urllib kullanarak python dosya indirme komut dosyası bulundu, ama ben buldum tüm örnekler aslında yukarıdaki php kodu aksine fiziksel dosyaya kaydedin.

PS: Birisi benim için 'fpassthru' ekleyin lütfen. Ben yeni bir etiket eklemek için izniniz yok.

0 Cevap