Use php to capture batch keywords. Baidu advertising website saved in txt file-PHP source code

Source: Internet
Author: User
Using php to capture batch keywords Baidu advertising websites saved in txt files combined with the server's scheduled tasks, you can regularly find the degree of competition for keyword ads

Php code

 ] *?>. *? <\/Script>/', "", $ contents);/* Remove js code */$ contents_left = ""; $ contents_right = ""; $ ads_left_green = ""; $ ads_left_white = ""; $ contentsbytwoside = ""; $ ads_right = "";/* Variable initialization */$ contentsbytwoside = explode ('

] * Class = \ "EC_im EC_fr EC_PP EC_idea1017 \"> .*?) ', $ Contents_right, $ ads_right); echo "------------ Keywords ads for". $ kw. "start ------------------------------------
"; Fwrite ($ fp," ---------- ". $ kw." ads start ----------------------- \ r \ n "); echo" left ads with green background is
";/* Print_r ($ ads_left_green [0]); */foreach ($ ads_left_green [0] as $ tg1) {preg_match ('/.*? <\/Span>/', $ tg1, $ tg11); fwrite ($ fp, strip_tags ($ tg11 [0]). "\ r \ n"); echo $ tg11 [0]."
";}; Echo"

-------------
"; Echo" left ads with white background is
";/* Print_r ($ ads_left_white [0]); */foreach ($ ads_left_white [0] as $ tg2) {preg_match ('/.*? <\/Span>/', $ tg2, $ tg22); fwrite ($ fp, strip_tags ($ tg22 [0]). "\ r \ n"); echo $ tg22 [0]."
";}; Echo"

-------------
"; Echo" right ads with is
";/* Print_r ($ ads_right [0]); */foreach ($ ads_right [0] as $ tg3) {preg_match ('/(.*? <\/Font>)/', $ tg3, $ tg33); fwrite ($ fp, strip_tags ($ tg33 [0]). "\ r \ n"); echo $ tg33 [0]."
";}; Echo" --------------- Keywords ads for ". $ kw." END ------------------------------------
"; Fwrite ($ fp ,"----------". $ kw. "ads End ------------------------- \ r \ n") ;}; fwrite ($ fp, date ("Y-m-d H: I: s "). "PHP code runs automatically! \ R \ n "); fclose ($ fp); function fetch ($ Date) {$ ch = curl_init (); $ timeout = 5; curl_setopt ($ ch, CURLOPT_URL, "$ Date"); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) "); curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ timeout); $ contents = curl_exec ($ ch); curl_close ($ ch); return $ contents;}?>

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.