我想知道是否可以用javascript打开文本文件(位置类似于:http://mysite.com/directory/file.txt)并检查文件是否包含给定的字符串/变量.
在php中,这可以通过以下方式轻松完成:
$file = file_get_contents("filename.ext");
if (!strpos($file, "search string")) {
echo "String not found!";
} else {
echo "String found!";
}
Run Code Online (Sandbox Code Playgroud)
有没有,最好是简单的方法来做到这一点?(我在nodejs,appfog上的.js文件中运行"function",如果可能的话).