2016-01-22 73 views
2

我在php中使用wget,我想給一個自定義名稱給我收到的響應文件。這裏是我的wget代碼。Wget自定義文件名

<?php 

exec('wget --header= --user-agent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1" --save-cookies 6.txt --keep-session-cookies --post-data="[email protected]&password=pass" http://example.com/login.php 2>&1', $output); 
print_r($output); ?> 

當我發送wget的要求,我會收到一個名爲的welcome.php文件,我會想重命名此文件來使用example.php,我們如何在wget的做到這一點?謝謝

+0

爲什麼使用wget代替流或捲曲函數?你檢查過curl --help還是他的manpage? (提示:在幫助文本中查找「輸出」) – johannes

+0

好吧,我會嘗試捲曲 – Sandra

+0

使用PHP模塊cURL而不是在控制檯上使用wget,因爲它可能很危險,並且會用來傷害你。 –

回答

0

我找到了辦法做到這一點。 --output-document = example.php將執行此操作。

<?php 

exec('wget --header= --user-agent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1" --save-cookies 6.txt --keep-session-cookies --post-data="[email protected]&password=pass" --output-document=example.php http://example.com/login.php 2>&1', $output); 
print_r($output); ?>