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...