graham23s Posted September 2, 2007 Share Posted September 2, 2007 Hi Guys, i was curious as to how i could go about reading parts of another webbsite, say i type a website url in and click submit the script would goto that page and read certain pieces of information i told it to kinda thing what would be the best way to go abput it, i have just mastered xml files you need to load them in first before you can grab the relevant data but not sure how i would go about doing the same for webpages any advice would be great cheers Graham Quote Link to comment https://forums.phpfreaks.com/topic/67670-how-to-read-another-website/ Share on other sites More sharing options...
pocobueno1388 Posted September 2, 2007 Share Posted September 2, 2007 You should look into cURL, I think thats what your looking for. Quote Link to comment https://forums.phpfreaks.com/topic/67670-how-to-read-another-website/#findComment-339920 Share on other sites More sharing options...
graham23s Posted September 2, 2007 Author Share Posted September 2, 2007 Hi Mate, thanks i will look into that now, is there any other way apart from cURL out of curiousity? thanks mate Graham Quote Link to comment https://forums.phpfreaks.com/topic/67670-how-to-read-another-website/#findComment-339921 Share on other sites More sharing options...
Hypnos Posted September 2, 2007 Share Posted September 2, 2007 If you want to do fancy things like cookies and sending POST data, you'll probably want to look at CURL. For just a basic webpage read, all of the fopen functions will work just as if it was a file on the local drive. <?php echo file_get_contents("http://www.google.com"); Quote Link to comment https://forums.phpfreaks.com/topic/67670-how-to-read-another-website/#findComment-339994 Share on other sites More sharing options...
tippy_102 Posted September 2, 2007 Share Posted September 2, 2007 I grab parts of a weather page to display on my site and Reg Ex is the key. My finished code is in the bottom post on this page: http://www.phpfreaks.com/forums/index.php/topic,120594.msg494739.html#msg494739 It should give you an idea of what needs to be done. Quote Link to comment https://forums.phpfreaks.com/topic/67670-how-to-read-another-website/#findComment-339999 Share on other sites More sharing options...
graham23s Posted September 2, 2007 Author Share Posted September 2, 2007 Hi Guys, it's really for getting the rating from imdn of a movie , for a review site code: <?php //=====================================================================================// // IMDB get rating... //=====================================================================================// $str_text = file_get_contents("http://www.imdb.com/title/tt0373883/"); $pattern = '/(h1|src)=[\'"]/'; preg_match_all($pattern, $str_text, $matches); echo "<pre>"; var_dump($matches); echo "</pre>"; ?> im not to sure how to set up the reg ex for the rating which is incased in this code: </div> <div class="general rating"> <div class="starbar static"><div class="outer"><div class="inner" style="width: 64px"></div></div></div> <b>User Rating:</b> <b>3.2/10</b> <small>(<a href="ratings">323 votes</a>)</small> <div class="bottom"> the 3.2/10 is the only bit im really after , any help on the reg ex code would be appreciated thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/67670-how-to-read-another-website/#findComment-340043 Share on other sites More sharing options...
tippy_102 Posted September 4, 2007 Share Posted September 4, 2007 That should be easy for someone who understands RegEx. The thing that trips me up is the fact that the part you need to match is spread over two lines. <b>User Rating:</b> <b>3.2/10</b> I hope someone solves this because I would like to see how it is done. Quote Link to comment https://forums.phpfreaks.com/topic/67670-how-to-read-another-website/#findComment-341023 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.