Php retrieves the content of a website and saves it as a TXT file. next time, it reads the content directly from the txt file-php Tutorial

Source: Internet
Author: User
Php retrieves the content of a website and saves it as TXT. next time, it reads the content of a website directly from the txt file and saves it as TXT. next time, it reads the content directly from the txt file.
File_put_contents seems to be saved!
How to write it! No!

The code is as follows!
  $line) { preg_match_all('|([^<>]+)|',$line,$result); $swfurl=$result[1][0]; if(!empty($swfurl)) return $swfurl; } } ?>
 


Reply to discussion (solution)

After obtaining the flash path, do you want to write the path to a text file?


.. Write a complete pull! No!

You want
Echo preg_replace ("/[&,?] /"," ", $ Flashurl );
Is the result written to the file?
$ S = preg_replace ("/[&,?] /"," ", $ Flashurl );
File_put_contents('file name .txt ', $ s );


Reply upstairs
:
I want
$ S = preg_replace ("/[&,?] /"," ", $ Flashurl); // obtain the result
File_put_contents('news.txt ', $ s); // save it to the txt file! Cache
// A lot of content is obtained! If flash URL obtains a news.txt file and saves it, the flash URL will be overwritten before it obtains other content! I have tested the content in news.txt!
// Save it! Http://bbs.csdn.net/1.php? Http://bbs.csdn.net/topics/
For example! The content is saved! When accessing this address! Not in the http://bbs.csdn.net/topics/ this get content directly re-news.txt saved content to get!

// A lot of content is obtained! If flash URL obtains a news.txt file and saves it, the flash URL will be overwritten before it obtains other content! I have tested the content in news.txt! How can we solve this problem by saving all the acquired data to a txt file or after several MB! Regenerate the news.txt news2.txt file! You need to save all the content obtained from none of the addresses! Next time you access the same address! Save it! Http://bbs.csdn.net/1.php? Http://bbs.csdn.net/topics/
For example! The content is saved! When accessing this address! Not in the http://bbs.csdn.net/topics/ this get content directly re-news.txt saved content to get!


Is there an append method?
You just need to take a closer look at the description of the file_pu_contents function, and your questions will no longer exist.

What really needs to be considered is: how do you separate multiple groups of data stored in one file?

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.