soddengecko Posted May 22, 2009 Share Posted May 22, 2009 hi all. i need some help if you can. I am trying to build a regex that will read cinema listings from my local cinemas website. the cinema site is here - http://www.odeon.co.uk/fanatic/film_times/s3/Cardiff/index.php So far I am using the regex below to get the data i need <?php $content = file_get_contents("http://www.odeon.co.uk/fanatic/film_times/s3/Cardiff/index.php"); $get_film_data_regex = '#<div\b[^>]*class=([\'"])?filminfos(?(1)\1)[^>]*>.*?</div>#s'; preg_match_all($get_film_data_regex,$content,$regexed_film_data); foreach ($regexed_film_data as $film_data) { foreach ($film_data as $data) { print "$data\n</div>\n\n"; } //nothing here } ?> The code above works fine, i get the data as one large chunk. My issue is that I want to be able to dissect the data into component parts for integration into my local Intranet site. (film title, certificate, film info and of course, the days and times) this is a sample of the data I will be trying to get the info from (below). this sample code is for one movie. the end of the data will increase/decrease depending on how many days and at what times the film is available, but it will always have this format, starting with <div class="rightside"> and the closing div after the view trailer link. (after the view trailer div has been closed) <div class="rightside"> <div class="filminfos"> <h1><a href="/fanatic/film_info/s3/Cardiff/m11900/12_Rounds/" title="Film information, ratings & guest reviews of "12 Rounds"">12 Rounds</a></h1> <a href="/fanatic/classifications/" title="More information about film classifications"><img src="http://m2.odeon.co.uk/img/certificates/greymiddle/12.gif" alt="Classification: 12A"></a><br class="cl"> <div class="details">Running time: 108 mins (Contains moderate action violence and moderate language)</div> </div> <div class="formats"></div> <div class="ratingBox clearfix"></div> </div> <div class="cl"></div> </div> <div class="timeslisting clearfix fRegular fWednesday fThursday"> <div class="dayline clearfix fWednesday"> <div class="day"><span>Wednesday</span></div> <div class="showingtimes"><span><a href="/fanatic/booking/s3/p1886900/" title="Book tickets online now for the movie "12 Rounds" on Wednesday, 21:20 at the ODEON cinema in Cardiff">21:20</a></span></div> <div class="cl"></div> </div> <div class="cl"></div> <div class="dayline clearfix fThursday"> <div class="day"><span>Thursday</span></div> <div class="showingtimes"><span><a href="/fanatic/booking/s3/p1886957/" title="Book tickets online now for the movie "12 Rounds" on Thursday, 21:20 at the ODEON cinema in Cardiff">21:20</a></span></div> <div class="cl"></div> </div> <div class="cl"></div> </div> </div> <a name="mf11438" id="mf11438"></a> <div class="filmdiv" id="f11438"> <div class="filmblock clearfix fSaturday fSunday fMonday fTuesday fWednesday fThursday"> <div class="leftside"><img src="http://m2.odeon.co.uk/_uploads/film_images/small/13724.jpg" alt="Film image of "17 Again""> <div class="trailerlink"><img src="http://m2.odeon.co.uk/img/content/view_trailer_darkblue.gif" alt=""> <a href="/fanatic/film_info/s3/Cardiff/m11438/17_Again/trailer/" title="Movie trailer, film information, guest reviews & ratings of "17 Again"">View Trailer</a></div> </div> can anyone point me in the direction i need to take to get this working? I have spent days on this, exhausted 100's of google search results and even downloaded an application that was supposed to help me work it out (yeah, i was grasping at straws) If you need more info, or I have missed something then let me know and I will get back to you TIA Mark Quote Link to comment https://forums.phpfreaks.com/topic/159220-solved-regex-help-needed-its-frying-my-mind/ Share on other sites More sharing options...
RussellReal Posted May 25, 2009 Share Posted May 25, 2009 add me to MSN: RussellonMSN@hotmail.com I was writing you a regex the other day, but the power went out and I lost it, so I want to help you out via msn that way atleast I can explain most of it to you, or send you previews, etc. Sorry Quote Link to comment https://forums.phpfreaks.com/topic/159220-solved-regex-help-needed-its-frying-my-mind/#findComment-841541 Share on other sites More sharing options...
soddengecko Posted May 25, 2009 Author Share Posted May 25, 2009 just added you to my msn - thank you Quote Link to comment https://forums.phpfreaks.com/topic/159220-solved-regex-help-needed-its-frying-my-mind/#findComment-841896 Share on other sites More sharing options...
RussellReal Posted May 26, 2009 Share Posted May 26, 2009 I just got on MSN but no add request =\ Quote Link to comment https://forums.phpfreaks.com/topic/159220-solved-regex-help-needed-its-frying-my-mind/#findComment-842030 Share on other sites More sharing options...
soddengecko Posted May 31, 2009 Author Share Posted May 31, 2009 I would like to say a huge thank you to RussellReal for helping me with this. He took his time to chat to me on msn and build a script that would do just what I needed. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/159220-solved-regex-help-needed-its-frying-my-mind/#findComment-846432 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.