PHP regular expression to write weather forecast thieves _ PHP Tutorial

Source: Internet
Author: User
PHP regular expression to write the weather forecast thief program. Previously, the content on other websites was automatically updated every day. I think this technology is amazing. I have been wondering why their website is not big, and it is impossible to have my own weather forecast. I have seen that the content on other websites is automatically updated every day. I think this technology is amazing.
I 've been wondering why their website is not big and it's impossible to have my own weather forecast center,
However, the weather forecast is automatically updated every day, and we know from others that it is because of the existence of something like a thief program ~
The thief program collects information from others' websites to their websites.
The principle of the collection program is to use regular expressions to match and replace the content read from other websites and display it on your own website.
Let's talk about a weather forecast thief program that I use php regular expressions.
Target site: ** weather forecast Network
Cause: there are not many codes, and it is easier to find relevant content for interception and positioning.
Steps:
① Reading the content of a web page with a string
Use the php function $ str = file_get_contents ("url"); read the content of the target site webpage and assign it to the $ str variable
② Use the regular expression function eregi to match the desired content
Eregi ("regular expression", "matched string $ str", "return value ");
③ Search for and replace some content
Use $ str2 = str_replace ("replaced string", "replaced string", "original string ");
Here, the function of string replacement is used to replace the path of the image in the weather forecast status so that the image can be properly displayed.
④ Output the result to the webpage
Echo $ str2;
OK ~ This is a simple thief program.
The final result is as follows:

Bytes. I have been wondering why their website is not big and it is impossible to have my own weather forecast...

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.