subhomoy Posted May 22, 2015 Share Posted May 22, 2015 hello every body, Currently i'm scraping web data for a demo project but i cant preg_match the value from this html.The html code is <div class="carouselContainer leftDisabled"> <ul class="carousel leftDisabled"> <li> <div class="thumbContainer"> <div class="thumb" style="background-image:url(http://img6a.flixcart.com/image/mobile/v/h/g/samsung-galaxy-core-2-sm-g355h-100x100-imadzb4ywyj25mw4.jpeg)" data-imageId="IMADZB4YWYJ25MW4"> </div> </div> </li> <li> <div class="thumbContainer"> <div class="thumb" style="background-image:url(http://img6a.flixcart.com/image/mobile/v/h/g/samsung-galaxy-core-2-sm-g355h-100x100-imadzb4zhk4855ny.jpeg)" data-imageId="IMADZB4ZHK4855NY"> </div> </div> </li> <li> <div class="thumbContainer"> <div class="thumb" style="background-image:url(http://img6a.flixcart.com/image/mobile/v/h/g/samsung-galaxy-core-2-sm-g355h-100x100-imadzwrpmdwhnxg7.jpeg)" data-imageId="IMADZWRPMDWHNXG7"> </div> </div> </li> <li> <div class="thumbContainer"> <div class="thumb" style="background-image:url(http://img6a.flixcart.com/image/mobile/v/h/g/samsung-galaxy-core-2-sm-g355h-100x100-imadzwvvz3deeh4c.jpeg)" data-imageId="IMADZWVVZ3DEEH4C"> </div> </div> </li> </ul> </div> The regex i've used is preg_match_all('|<div class="carouselContainer leftDisabled"+>(.*)</div+>|U',$txt,$matches3); I want only the images images url from that specific block. Can anybody help me in this plz... Quote Link to comment https://forums.phpfreaks.com/topic/296450-need-help-in-regex/ Share on other sites More sharing options...
Ch0cu3r Posted May 22, 2015 Share Posted May 22, 2015 Don't use regex for parsing HTML. Instead you should query the DOM to retrieve the content you want from a HTML element on a webpage. You may find using simplehtmldom a lot simpler to use, it uses jquery like syntax for querying the DOM. Quote Link to comment https://forums.phpfreaks.com/topic/296450-need-help-in-regex/#findComment-1512463 Share on other sites More sharing options...
7snovic Posted July 5, 2015 Share Posted July 5, 2015 I want only the images images url from that specific block. if you only want the images from the that block , you can use this pattern #background-image:url\((.*?)\)"# Quote Link to comment https://forums.phpfreaks.com/topic/296450-need-help-in-regex/#findComment-1515602 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.