1

当我在浏览器中键入网页的 URL 时,我可以访问网页。但是,在使用 curl 访问该网页的详细信息时,我在屏幕上收到消息

User information is disabled.
This operation cannot be accepted. User certification is invalid or date expired.
Update page.

我可以通过在浏览器中输入该打印机的 IP 来访问我的网络打印机(佳能 IR3570)的详细信息。这将打开远程 UI。但是,它似乎不适用于 curl。

这是我在 PHP curl 中的代码

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"URL");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1');

$result= curl_exec($ch);
echo $result;
curl_close ($ch);    

这样的消息可能是什么原因?

4

3 回答 3

0

尝试添加:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
curl_setopt($ch, CURLOPT_USERAGENT, "User-Agent  Mozilla/5.0");
curl_setopt($ch, CURLOPT_HEADER ,1);  // DO NOT RETURN HTTP HEADERS
于 2012-07-05T17:56:33.873 回答
0

UserAgent 设置在哪里?他们可能会过滤请求。

于 2012-07-05T17:58:59.587 回答
0

这不是 CURL,但它适用于 Visual Basic 2012 - 其中一个标题为我解决了它

Sub Main()
    Dim web_client As New System.Net.WebClient
    Dim baseDate As DateTime = New DateTime(1970, 1, 1)
    Dim diff As TimeSpan = DateTime.Now - baseDate
    web_client.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
    web_client.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3")
    web_client.Headers.Add("Accept-Encoding", "gzip, deflate, sdch")
    web_client.Headers.Add("Accept-Language", "en-US,en;q=0.8")
    web_client.Headers.Add("Cookie", "iR = 1711753823")
    web_client.Headers.Add("Host", "172.23.100.14")
    web_client.Headers.Add("Referer", "http://172.23.100.14/jlp.cgi?Flag=Html_Data&LogType=0&Dummy=" & diff.Milliseconds)
    web_client.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31")
    web_client.DownloadFile("http://172.23.100.14/pprint.csv?Flag=Csv_Data&LogType=0&Dummy=" & diff.Milliseconds, "P:\Transfer\mstavers\printlogs\" & Format(Now, "yyyy-MM-dd-hh-mm-ss") & ".csv")
End Sub
于 2013-05-02T13:10:32.457 回答