搜索远程页面的字符串[关闭]

Is it possible to search a remote page with a given URL for a given string, and indicate whether it exists, and if so, some indication of where it was found?

For instance, "Post Your Question" is included on this site https://stackoverflow.com/questions/ask.

In addition to searching just the page given by the URL, I would also like to search any JS or CSS links.

You can use the PHP Simple HTML DOM Parser to traverse through the contents of an html file.

Doing something like this:

$html = file_get_html('http://stackoverflow.com/questions/ask');
$htmlstring = $html->plaintext;
if(strstr($htmlstring, 'Post Your Question') === true)
  // do your stuff here

Then to get the url to css or js:

foreach($html->find('link') as $css) {
  $cssHref = $css->href;
  //load the css, parse or whatever
}
foreach($html->find('script') as $script) {
  $jsSrc = $script->src;
  //load js, parse or whatever
}

From there you can grab the css or js source url and do what you want with it.