简体   繁体   English

如何使用curl或wget访问(而非下载)页面

[英]How to visit (not download) a page using curl or wget

I am very new to wget/curl. 我对wget / curl非常陌生。 I am trying to get a page to execute its html/scripts using wget/curl. 我正在尝试让页面使用wget / curl执行其html / scripts。 I do not care about downloading the actual page, just that the scripts on the page run. 我不在乎下载实际页面,只是在运行页面上的脚本即可。 Is there a command to do this? 有命令执行此操作吗?

Thanks! 谢谢!

cURL and wget are used to transfer files/content to/from a specified location. cURL和wget用于向/从指定位置传输文件/内容。 As such, cURL and wget are neither suitable for actually rendering web pages nor executing JavaScript on those webpages. 因此,cURL和wget既不适合实际呈现网页,也不适合在这些网页上执行JavaScript。 While cURL can be used to output received data to stdout, it is still not designed to render that data. 尽管可以使用cURL将接收到的数据输出到stdout,但仍不能将其设计为呈现该数据。

If you would like to use the terminal to execute JavaScript within a webpage, you may want to consider looking into PhantomJS . 如果您想使用终端在网页中执行JavaScript,则可能需要考虑研究PhantomJS PhantomJS can load local HTML files and interact with/execute their JavaScript. PhantomJS可以加载本地HTML文件并与JavaScript交互/执行。

If you just want to call a PHP script you can do: 如果您只想调用PHP脚本,则可以执行以下操作:

curl http://your-domain.com/script.php

But with just wget your script will be downloaded: 但是只要有了wget,您的脚本就会被下载:

wget http://your-domain.com/script.php

But with wget -q -O you can call the script like curl: 但是使用wget -q -O可以像curl一样调用脚本:

wget -q -O http://your-domain.com/script.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM