My PHP Learning notes: PHP Universal collection Program

Source: Internet
Author: User
Tags preg

The basic steps for building a PHP collection program are:

What is a collection program? Get Remote Data (text, pictures, pictures) and quickly save to a local or specified address.

such as weather Forecast (thief procedure):

Remote access-"Replace content-" show to users

such as real-time updates of news (capture content):

Remote access--"Extract content-" Classified storage-"Read content---" Display content



*************************

Design PHP to collect inbound UML

List Regular:

The terminal is regular:

**************************

file_get_contents () Get remote page content

Preg_match_all () match list

Preg_match () matching terminal

Preg_replace (): Filter terminal

**************************

Create a new list file: lb.php

echo $con =file_get_cotents ($_get[url]);

$preg = "#


Pg_match_all ($preg, $conn, $arr);

foreach ($arr [1] as $id = + $v) {

echo $v. " "Arr[2][$id]." <br> ";

}


New VI. PHP Get title


vi.php


$con =file_get_contents ();

$preg = "<title> (. *) </title>/ius";//case insensitive, prevent greedy match, prevent line break

Echo ZZ ($preg, $con);

Function zz ($preg, $con, $num =1) {

Preg_match ($preg, $con, $arr);

return $arr [$num];

}

echo $arr [1];//get title

echo "<a href=vi.php?url=". $v. " > ". arr[2][$id]." <br> ";

======================================

PHP100:83: Acquisition Program


lb.php

<?php

if ($_get[id]) {

$con =file_get_cotents ($_get[url].$_get[id]. " sHTML ");

$preg = "/


Perg_match_all ($preg, $conn, $arr);

foreach ($arr [1] as $id = + $v) {

echo $v. " "Arr[2][$id]." <br> ";

}

$_get[id]++;


echo "<script>location.href= ' lb.php?id= '. $_get[id]." </script> ";

}

?>


Http://www.xinhuanet.com/finance/tzxx.htm


===============================================================

Operation Steps:

1. Create a new Database Caiji,tep_url table, id,title,content,11, 100,150

2. Create a new conn.php, insert the statement can be inserted by phpMyAdmin a statement simple to get

3. Create a new vi.php

4. Get the next article in a single storage.


List of temporary paths:

Perfect my inbound table.



What if you delete one of the ID values? Removed the 9th article!

Add a statement

$sql 2= "SELECT * from Tmp_url where id> ' $gid ' ORDER by ID ASC Limit 1


This article is from "Pico Zhang" blog, please make sure to keep this source http://raojiadashaoye.blog.51cto.com/7167615/1426141

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.