In the last article, we have collected a list of news page data, the next thing to do is to read from the database required to collect the URL, the page crawl on the line
Create a new content table
However, it is important to note that the collection URL can not be used to increase the number of methods to collect, because the data table may be intermittent ID, such as id=9,id=11, when the collection of id=10, the URL is blank, which may result in the collection of empty fields.
One of the techniques used here is the database query statement, when we collect the first data, to determine whether there are more than this ID ID number in the database, if there is, read a, query information repeat the above work.
The specific code is as follows:
<?php
include_once ("conn.php");
$id = (int) $_get[' id '];
$sql = "SELECT * from list where id= $id";
$result =mysql_query ($sql);
$row =mysql_fetch_array ($result);//obtain the corresponding URL address
$content =file_get_contents ($row [' url ']);
$pattern = "/<dd class=\" Datawrap\ "> (. *) <\/dd>/ius";
Preg_match ($pattern, $content, $info)//get content to store info
echo $title = $row [1]. " <br/> ";
echo $content = $info [0]. "
This way we want the news content on the collection, and then only need some of the data to organize the style of the line.