PHP Regular Expression Write weather forecast thief program _php tutorial

Source: Internet
Author: User
Previously saw people on the site of the content is automatically updated every day, think this technology is magical.
Also have been wondering why their website is not big, it is impossible to have their own forecast center,
But the weather forecast is automatically updated every day, and then learned from others, it is because there is a thief program this thing exists ~
The thief procedure says the good point is collects the procedure, collects other people's website the information to own website.
The principle of the acquisition program is to use regular expressions to match and replace the content read from other sites, and then display to their own site.
Let's say I use a PHP regular expression to implement a weather-forecasting thief program.
Target site: * * Weather Forecast Network
Reason: Code is not many, it is easier to find relevant content to do intercept positioning
Implementation steps:
① read ask Skynet Web content with string
Use the PHP function $str=file_get_contents ("url"), read the contents of the target Web page and assign the value to the $STR variable
② matches the required content with regular expression function eregi
Eregi ("Regular expression", "matched string $str", "return value");
③ Find and replace some content
Use the $str2=str_replace ("replaced string", "replaced by the word string", "original Strings");
Using the string substitution function here is to replace the path of the picture of the weather forecast status, so that the picture can be displayed normally
④ output to the Web page
echo $str 2;
Ok~ to this a simple thief program is done.
The following is the final effect:

http://www.bkjia.com/PHPjc/478607.html www.bkjia.com true http://www.bkjia.com/PHPjc/478607.html techarticle previously saw people on the site of the content is automatically updated every day, think this technology is magical. Also have been wondering why their website is not big, also can not have their own weather forecast pre ...

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