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.