Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何使用curl向Google发送请求_Linux_Curl - Fatal编程技术网

Linux 如何使用curl向Google发送请求

Linux 如何使用curl向Google发送请求,linux,curl,Linux,Curl,我在Linux上工作,尝试使用curl向Google发送请求,并将其回复保存为html文件。 当我使用谷歌搜索某些东西时,比如字符串“abc”,我发现谷歌的链接是: 所以我试着这样: curl https://www.google.lu/#q=abc -o res.html 但是res.html只是谷歌的主页,而不是搜索“abc”的结果。 如何做?在客户端用JavaScript处理之后的任何事情,这就是为什么它不能与curl一起工作的原因 您可以在https://www.google.com/

我在Linux上工作,尝试使用
curl
向Google发送请求,并将其回复保存为html文件。

当我使用谷歌搜索某些东西时,比如字符串“abc”,我发现谷歌的链接是:

所以我试着这样:

curl https://www.google.lu/#q=abc -o res.html
但是
res.html
只是谷歌的主页,而不是搜索“abc”的结果。

如何做?

在客户端用JavaScript处理
之后的任何事情,这就是为什么它不能与
curl
一起工作的原因

您可以在
https://www.google.com/search?q=abc

它似乎会阻止您,除非您还欺骗用户代理,所以总而言之:

curl \
  -A 'Mozilla/5.0 (MSIE; Windows 10)'  \
  -o res.html \
  "https://www.google.com/search?q=abc"
#
之后的任何内容都是用JavaScript在客户端处理的,这就是为什么它不能与
curl
一起工作的原因

您可以在
https://www.google.com/search?q=abc

它似乎会阻止您,除非您还欺骗用户代理,所以总而言之:

curl \
  -A 'Mozilla/5.0 (MSIE; Windows 10)'  \
  -o res.html \
  "https://www.google.com/search?q=abc"