Php's question about loops! (Collect webpage content)

Source: Internet
Author: User
Php's question about loops! (Collecting webpage content) I am working on a small program for collecting Forum content,
This is the way to challenge web page collection.
If ($ _ GET [id] <= 130000 & $ _ GET [id]) {
$ Url = "http://bbs.misranim.com/thread-". $ _ GET [id]. "-1-1.html ";

However, I used the while loop for convenience.
$ P = 0;
While ($ p <= 130000 ){
$ Url = "http://bbs.misranim.com/thread-". $ p. "-1-1.html ";
$ P ++;

The problem arises. each time a blank page is deleted, the content is collected to the database.
When you use if ($ _ GET [id] <= 130000 & $ _ GET [id]), the deleted blank page is skipped directly,
When the while or for loop is used, this problem occurs when the deleted blank page is encountered.

Figure: copy the content of the previous page directly when an empty page is encountered. for example, if 13th posts have content, but 14th to 17 posts are empty pages deleted, it will add the content of 13 posts to these posts, and the content will be similar later!



When you use if ($ _ GET [id] <= 130000 & $ _ GET [id]), the deleted blank page is skipped directly.
There are no content in the last few of the 13 posts, so I jumped to the first post.

I want this effect.

Yes
If (strlen ($ txt)> 5) // The content is large and 5 characters are collected to the database.
{
$ Db-> insert ("insert into bbs_caiji (col_date, title, txt, url, type, source) VALUES ('". $ col_date. "','". $ title1 ."','". $ txt. "','". $ url. "', 'bbs', 'misranim ')");
}


Why does this problem occur when the while and for loops are used?


Reply to discussion (solution)

The first line is jump not a challenge.

This should not happen.

Generation? Incomplete, only look at the generation provided? Yes? Yes ?? .

Every cycle? And then clear all the $ txt files? Null ??.

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.