我需要帮助,我想编写一个程序来搜索源代码中的单词.
这是Python中的一个例子:
import urllib2, re
site = "http://stackoverflow.com/"
tosearch = "Questions"
source = urllib2.urlopen(site).read()
if re.search(tosearch,source):
print "Found The Word", tosearch
Run Code Online (Sandbox Code Playgroud)
<?php
$site = "http://stackoverflow.com/";
$tosearch = "Questions";
$source = file_get_contents($site);
if(preg_match("/{$tosearch}/", $source)): // fixed, thanks meouw
echo "Found the the word {$tosearch}";
endif;
?>
Run Code Online (Sandbox Code Playgroud)