about problems with array loops

Source: Internet
Author: User
Questions about the array loop
Code a little more inconvenient to post, but I hope that friends can give me a thought, here first thank you
$_array_article=array ("http://blog.csdn.net/anewczs/article/details/6617391");
$_array_article[]= "http://blog.csdn.net/tianlesoftware/article/details/6723117";

foreach ($_array_article as $value) {
$spider->begin_url= $value;
File_get_contents ($spider->begin_url);
_spider ($spider->fetch_turl ($spider->begin_url));
}


Here is part of the code, through a chain of arrays to deal with the individual links, but in another case: the array element is greater than one error, I feel that after the loop has been carried out once, some of the memory values affect the second loop, so that caused the error, How can I do what I need two global arrays can add new elements continuously, all other memory values are emptied?


------Solution--------------------
Can not be so caught, it is easy to fall into the capture of the dead loop.
Crawling is usually the case
#1. Create a file to save the URL
#2. Fetch the URL appended to the file to go
#3. Read the URL in the file, line up the data, repeat it, #3

There will be some problems, such as how to avoid the same link crawl two times, how to limit the crawl target to a domain name. Wait a minute. I believe you can solve these small problems.

  • Related Article

    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.