php - Blocking a keyword when loading a table -
i phone call below php file loads info table using curl, below, trimming downwards prevent showing hyperlinks , replacing string prevent hostname check (the lastly part)
<?php function curl($url){ $headers[] = "user-agent:mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.9.2.13) gecko/20101203 firefox/3.6.13"; $headers[] = "accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; $headers[] = "accept-language:en-us,en;q=0.5"; $headers[] = "accept-encoding:gzip,deflate"; $headers[] = "accept-charset:iso-8859-1,utf-8;q=0.7,*;q=0.7"; $headers[] = "keep-alive:115"; $headers[] = "connection:keep-alive"; $headers[] = "cache-control:max-age=0"; $curl = curl_init(); curl_setopt($curl, curlopt_url, $url); curl_setopt($curl, curlopt_httpheader, $headers); curl_setopt($curl, curlopt_encoding, "gzip"); curl_setopt($curl, curlopt_returntransfer, 1); curl_setopt($curl, curlopt_followlocation, 1); $data = curl_exec($curl); curl_close($curl); homecoming $data; } $a = curl('http://www.domain.com/table'); $regex = '#<a href=[^>]+>([^<]*)</a>#'; $b = preg_replace('#<a.*?>(.*?)</a>#i', '\1', $a); $c = str_replace('feed_container.innerhtml+=', 'aa=', $b); $d = str_replace("if(location.host.indexof('hostnamekeyword')!=-1||location.host.indexof('hostnamekeyword')!=-1)", "if (2==3)", $c); print $d; ?>
what trying right following: if there "keyword2" in row when importing, ignores entire row , not print out. (do not show it)
even if code removes keyword2, job.
here finish code domain.com/table
function load_dse(){var feed_container=document.getelementbyid('filetoload');if(location.host.indexof('hostnamekeyword')!=-1||location.host.indexof('hostnamekeyword')!=-1){feed_container.innerhtml='<p>error</p>';}else{var head=document.getelementsbytagname('head')[0];var css=document.createelement('link');css.type='text/css';css.rel='stylesheet';css.href='http://www.domain.com/table';head.appendchild(css);var html='<table id=\"title\" border=\"0\"><tr><td class=\"first\"> </td><th class=\"second\">title2</th><th class=\"third\">from / time</th></tr><tr class=\"alt\"><td class=\"first\"><img src=\"http://domain.com/image1.gif\" /></td><td class=\"second\">somthing keyword2 somthing else</td><td class=\"third\"><b>from</b>: e***i</td></tr><tr><td class=\"first\"><img src=\"http://domain.com/image2.gif\" /></td><td class=\"second\">somthing keyword3 else bla bla bla</td><td class=\"third\"><b>from</b>: r***o</td></tr><tr><td class=\"first\"> </td><td class=\"second\"><b>title3</b>: <a href=\"http://domain.com\" rel=nofollow>maintitle</a></td><td class=\"third\">07-oct-14 03:05</td></tr><tr class=\"alt\"><td class=\"first\"><img src=\"http://domain.com/image4.gif\" /></td><td class=\"second\">somthing3 bla bla bla keyword4 bla bla somehting else bla</td><td class=\"third\"><b>from</b>: r***o</td></tr><tr class=\"alt\"><td class=\"first\"> </td><td class=\"second\"><b>item</b>: <a href=\"http://domain/com\" rel=nofollow>maintitle2</a></td><td class=\"third\">07-oct-14 03:05</td></tr></table>';feed_container.innerhtml=html;feed_container.innerhtml+='<p><a href="http://www.domain.com/" style="display:inline;font-size:11px;color:#808080;text-decoration:none;font-family:helvetica,arial,sans-serif">title-new<span style="color:#4374b7">another title</span></a></p>';}} if(typeof window.addeventlistener!="undefined") window.addeventlistener("load",filetoload,false);else if(typeof window.attachevent!="undefined"){window.attachevent("filetoload",lfiletoload);} else{if(window.onload!=null){var oldonload=window.onload;window.onload=function(e){oldonload(e);window[filetoload]();};} else window.onload=filetoload;}
please help, tried different methods, no matter do, not work.
check if helpful:
$e = preg_replace('#<tr.*?>.*keyword2.*?<\/tr>#i', '', $d); print $e;
this remove table rows contain keyword2. guess need.
you can check results here: http://regex101.com/r/qq2de4/9 explanations , tests. nice site!
php
No comments:
Post a Comment