【问题标题】:Wget Custom File Namewget 自定义文件名
【发布时间】:2016-01-22 13:23:56
【问题描述】:

我在 php 中使用 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=myemail@gmail.com&password=pass" http://example.com/login.php 2>&1', $output);
print_r($output);  ?>

当我发送wget请求时,我会收到一个名为welcome.php的文件,我想将此文件重命名为example.php,我们如何在wget中做到这一点?谢谢

【问题讨论】:

  • 你为什么使用 wget 而不是流或 curl 函数?您检查过curl --help 或他的联机帮助页吗? (提示:在帮助文本中寻找“输出”)
  • 使用 PHP 模块 cURL 而不是通过控制台使用 wget,因为它可能很危险并且会伤害您。

标签: php http httprequest wget


【解决方案1】:

我找到了这样做的方法。 --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=myemail@gmail.com&password=pass" --output-document=example.php http://example.com/login.php 2>&1', $output);
print_r($output);  ?>

【讨论】:

猜你喜欢
  • 2010-12-11
  • 2015-04-29
  • 1970-01-01
  • 2019-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-30
  • 1970-01-01
相关资源
最近更新 更多