_php example of simple data acquisition program based on PHP

Source: Internet
Author: User
When it comes to acquisition, it's nothing more than a remote access to information------Read more

It's an enhanced version of the Simple Thief program.

Here is the corresponding core code (don't do bad things oh ^_^)

The content to be collected is an announcement on a game website, such as:

Basic page information can be obtained first using file_get_contents and simple regularization

Organize the basic information, collect the storage:

<?php  include_once ("conn.php");   if ($_get[' id ']<=8&&$_get[' id ') {     $id =$_get[' id '];    $conn =file_get_contents ("http://www.93moli.com/news_list_4_$id.html");//Get page content    $pattern = "/
  • /ius ";//Regular Preg_match_all ($pattern, $conn, $arr);//match content to arr array //print_r ($arr);d ie; The foreach ($arr [1] as $key + $value) {//two-D array [2] corresponds to the same ID as [1], utilizing the key $url = "http://www.93moli.com/". $arr [2][$key] ; $sql = "INSERT into List (Title,url) value (' $value ', ' $url ')"; mysql_query ($sql); echo "$value". "
    "; } $id + +; echo "Collecting URL data list $id ... Please later ... "; echo "";} else{ echo "Collect Data end. "; }? >
  • conn.php is a database connection file

    list.php is this page

    Because the data to be collected is paginated, and the page address is a regular increment, so I used the JS jump code, the use of ID value to control the number of pages collected, but also to avoid too large for a loop.

    Easy Data Warehousing, the next article to write about the specific URL to collect information process.

  • 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.