jamesxg1 Posted July 20, 2009 Share Posted July 20, 2009 I am using CURL to rip content from google map's and in the source code i get this <div class=rescat>Category: <span dir=ltr>Restaurants - <b>Indian</b></span></div><div align=left><div class=s dir=ltr>"Indian and Thai food: but servers Bengali, Thai and even some Japanese food. So the starters include Chicken Tikka, Prawn Toast and Sword Fish Tempura <b>...</b>"</div></div><span class="f noprint"><a class=f href=/local_url?q=http://www.bluecobra.com/&dq=indian+delivery+in+berkshire&f=q&source=s_q&hl=en&geocode=&sll=52.173511,-0.411301&sspn=0.205075,0.441513&ie=UTF8&ll=52.089633,-0.411301&spn=0.205462,0.441513&z=11&view=text&ei=-NRkSqfsAo-wjAeD2PCTDA&mpnum=9&attrid=&oi=maps_text&sa=X&ct=website&cd=1&cad=cid:16738287191014861748&s=ANYYN7lSZHqg0Dm0IkVVTQ1Iv0QgZeE_HA dir=ltr>Website</a>‎ - <a class=f href=/maps?li=d&hl=en&f=d&iwstate1=dir:to&daddr=20+High+St,+Theale,+Reading,+RG7+(Blue+Cobra+Piano+Restaurant)&geocode=CT8mHnpGvy10FWnfEAMd6Zfv_w&iwloc=1&dq=indian+delivery&ei=-NRkSqfsAo-wjAeD2PCTDA dir=ltr>Directions</a>‎</span></div></div></div></td></tr><tr><td class=res><div class=one><div class="icon lsicon" log=miw id=marker_B_2><img alt=B src=http://maps.gstatic.com/intl/en_uk/mapfiles/transparent.png class="mp iconB" /></div><div class="text vcard indent block" id=panel_B_2><div class="name lname"><a href=/maps?f=q&source=s_q&hl=en&geocode=&q=indian+delivery+in+berkshire&sll=52.173511,-0.411301&sspn=0.205075,0.441513&ie=UTF8&view=text&ei=-NRkSqfsAo-wjAeD2PCTDA&attrid=&latlng=16621787129134884716&cd=2 log=miw id=link_B_2><span id=title class="fn org" dir=ltr>Spice <b>Indian</b> Restaurant</span>‎</a><span><a class=f href=/maps?f=q&source=s_q&hl=en&geocode=&q=indian+delivery+in+berkshire&sll=52.173511,-0.411301&sspn=0.205075,0.441513&ie=UTF8&view=text&ei=-NRkSqfsAo-wjAeD2PCTDA&attrid=&latlng=16621787129134884716&cd=2&dtab=2&pcsi=16621787129134884716,0 log=miwd id=nrev_B>1 review</a> - <a class="f nw" href=https://www.google.com/accounts/ServiceLogin?service=local&hl=en&nui=1&continue=http://maps.google.co.uk/maps%3Ff%3Dq%26source%3Ds_q%26hl%3Den%26geocode%3D%26q%3Dindian%2Bdelivery%2Bin%2Bberkshire%26sll%3D52.173511,-0.411301%26sspn%3D0.205075,0.441513%26ie%3DUTF8%26view%3Dtext%26ei%3D-NRkSqfsAo-wjAeD2PCTDA%26attrid%3D%26dtab%3D2%26cid%3D16621787129134884716%26iwd%3D1%26iwloc%3DA%26action%3Dopen log=miwd id=wrev_B>Write a review</a></span></div> is there some sort of code i can use that will scan for this code and then remove it all ?, many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/166693-solved-php-html-start-to-end-replace-help/ Share on other sites More sharing options...
.josh Posted July 20, 2009 Share Posted July 20, 2009 preg_replace Quote Link to comment https://forums.phpfreaks.com/topic/166693-solved-php-html-start-to-end-replace-help/#findComment-878977 Share on other sites More sharing options...
jamesxg1 Posted July 20, 2009 Author Share Posted July 20, 2009 @Crayon Violent, I had a look at using that previous but im stumped if i can use it i dont have a clue how to work it Quote Link to comment https://forums.phpfreaks.com/topic/166693-solved-php-html-start-to-end-replace-help/#findComment-878979 Share on other sites More sharing options...
jamesxg1 Posted July 20, 2009 Author Share Posted July 20, 2009 i need some sort of function that will search for this at the beginning <div class=rescat>Category: and this at the end Write a review</a></span></div> and and replace everything starting with <div class=rescat>Category: and ending in Write a review</a></span></div> James. Quote Link to comment https://forums.phpfreaks.com/topic/166693-solved-php-html-start-to-end-replace-help/#findComment-878992 Share on other sites More sharing options...
.josh Posted July 20, 2009 Share Posted July 20, 2009 Right. You need.... preg_replace What part of it are you having trouble with? Quote Link to comment https://forums.phpfreaks.com/topic/166693-solved-php-html-start-to-end-replace-help/#findComment-878997 Share on other sites More sharing options...
jamesxg1 Posted July 20, 2009 Author Share Posted July 20, 2009 Right. You need.... preg_replace What part of it are you having trouble with? Well, At the risk of me sounding dumb, All of it lol , i just need a replacer that will search the above from start to end and replace all that contents. Quote Link to comment https://forums.phpfreaks.com/topic/166693-solved-php-html-start-to-end-replace-help/#findComment-878999 Share on other sites More sharing options...
jamesxg1 Posted July 20, 2009 Author Share Posted July 20, 2009 anyone ? Quote Link to comment https://forums.phpfreaks.com/topic/166693-solved-php-html-start-to-end-replace-help/#findComment-879025 Share on other sites More sharing options...
.josh Posted July 20, 2009 Share Posted July 20, 2009 $string = preg_replace('~<div class=rescat>Category:.*?Write a review</a></span></div>~is','',$string); Quote Link to comment https://forums.phpfreaks.com/topic/166693-solved-php-html-start-to-end-replace-help/#findComment-879030 Share on other sites More sharing options...
jamesxg1 Posted July 20, 2009 Author Share Posted July 20, 2009 OMG!. Crayon Violent You are like literally PHP MASTER!, i am forever your slave!. lol. Thanks dude, James. Quote Link to comment https://forums.phpfreaks.com/topic/166693-solved-php-html-start-to-end-replace-help/#findComment-879040 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.