【问题标题】:Search based on php url for keyword根据 php url 搜索关键字
【发布时间】:2015-03-15 04:06:06
【问题描述】:

基本上我想做的是搜索一个网址。

示例 http://www.example.com/?page=X

其中 X = 1 到 1500

然后在混乱中找到一个关键字。

我想也许可以使用 sh 脚本来执行此操作,但如果有人有另一种快速而肮脏的方式,那就太棒了。

【问题讨论】:

  • “然后在乱七八糟的地方找一个关键词。”这是什么意思

标签: php search web web-crawler


【解决方案1】:

问题模糊不清,但如果你只是想搜索一个关键字,然后打印一些东西,如果找到:

<?php
$url = "http://www.example.com/?page=$x";
$keyword = "keyword"; //The keyword you are looking for

/* Go from X=1 to X=1500 */
for($x=1; $x<=1500; $x++) {
    $current_page = file_get_contents($url); //This will parse the html into a single string
    if(strpos($current_page, $keyword) !== false) {
      echo "found keyword: $keyword on page $x \n";
    }
}

文档:
http://php.net/strpos
http://php.net/manual/en/function.file-get-contents.php

【讨论】:

    猜你喜欢
    • 2012-02-22
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 2013-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多