1

我安装了 Apache 2.2。我可以通过 Firefox 使用 127.0.0.1 或 192.168.1.7 加载本地网页。(我正在加载的网页存储在我的硬盘上。)当我尝试使用 VBScript 访问这些地址时,它不起作用。如果我使用 VBScript 访问网络,它可以正常工作,包括如果我在域名中使用 IP 地址。

这是不适用于本地提供的文件的 VBScript,但可以用于 Internet 上的相同文件。(如果我使用 127.0.0.1 或 192.168.1.7,则会将“错误”写入文件)此脚本将网页上的所有 URL 写入文本文件。

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)

'  The Chilkat Spider component/library is free.
set spider = CreateObject("Chilkat.Spider")

spider.Initialize "http://192.168.1.7/index.htm"
spider.AddUnspidered "http://192.168.1.7/index.htm"

success = spider.CrawlNext()

if success then 

For i = 0 To spider.NumOutboundLinks - 1
    outFile.WriteLine(spider.GetOutboundLink(i))
Next

else
    outFile.WriteLine("Error.")
end if 

以下是一些 Apache 访问日志。

Apache's log, running the VBScript (http://192.168.1.7/index.htm)
... GET /robots.txt HTTP/1.1" 404 208
... GET /index.htm HTTP/1.1" 200 365184
... GET /index.htm HTTP/1.1" 200 365184
Apache's log, loading the same from Firefox
... GET /index.htm HTTP/1.1" 200 365184
... GET /index_files/rsAItRhddGWakWTu2xcFYn5VJXiw_002.txt HTTP/1.1" 200 533363
... (additional accesses, with 200 and then different numbers)

关于这个日志,本地保存的文件是一个谷歌搜索结果页面。(用于测试。我不会将它用于 Google。)VBScript 将在实时互联网版本上运行,而不是在本地提供的副本上运行。Firefox 加载本地提供的文件,它看起来与实时文件相同。

我的防火墙已关闭。阿帕奇 2.2;视窗 XP SP3

4

1 回答 1

0

我想您会在对Apache 500 Error due to User Agent 的响应中找到答案?. 本质上,Apache 已设置为忽略带有空 UserAgent 字符串的请求。响应是指相关的UserAgent/.htaccess question

另请参阅如何使用 .htaccess 从您的网站阻止不需要的机器人

于 2013-04-13T07:58:24.973 回答