Good day.

Help to realize such a task. It is necessary to follow the external link, find a specific text there and if it is there, perform an action, if not, take another link. Links in the database.

I'm just learning php and I don’t know how to make it look for a specific text for a specific link.

  • 2
    At least show an example. - Shevsky pm

3 answers 3

You most likely need regular expressions. Here you can read .

    Action algorithm

    1. Connect to the Base.
    2. Get out all the links and work with each in the cycle

    CYCLE:

    1. Use the cURL library to load the page.
    2. With the help of regulars or functions of working with strings (they are faster than regulars) you determine whether there is necessary infa or not. Depending on the result - performs the function.

    But for a beginner it will be difficult

      Thank you Ale_x. On the same day did. That's just to check the performance could in a day. The site that I parsed, blocked the ip of my server. Blocks already on the 3rd link: (Sorry that under the new login, mail was stolen.

      <?php include_once('configuration.php'); $link = mysql_connect($mysqlhost, $mysqllogin, $mysqlpass); if (!$link) { die('Ошибка соединения: ' . mysql_error().'<br />'); } echo 'Успешно соединились'.'<br />'; $db_selected = mysql_select_db('xmlfind5', $link); if (!$db_selected) { die ('Не удалось выбрать базу xmlfind5: ' . mysql_error().'<br />'); } echo " Выбрали базу <br />"; $sql = "SELECT * FROM xml"; $result = mysql_query($sql); $i=0; while ($row = mysql_fetch_array($result, MYSQL_NUM)){ if ($i<1800994){ $text = file_get_contents($row["2"]); if (preg_match( '/<title>(удалена страничка)<\/title>/ is' , $text , $title )){ echo $row["2"]."<br>"; $query = 'DELETE FROM xml WHERE id IN ('.$row["0"].')'; mysql_query( $query ); } $i++; } } echo "Всего проверил: $i"."<br>"; ?>