rasmushs Posted November 14, 2013 Share Posted November 14, 2013 Hi everybody I'm pretty new in coding but hope you can help me! My problem: I want my webpage always to show the first news story from http://www.bbc.com/. So every time a user goes to my website the first news story from bbc is showed (like on bbc), but when the user clicks on the link on my webpage he's redirected to bbc.com How is that possible to create? Quote Link to comment https://forums.phpfreaks.com/topic/283897-getting-content-from-another-website/ Share on other sites More sharing options...
dalecosp Posted November 14, 2013 Share Posted November 14, 2013 I'd go to BBC's site and see if they have an RSS feed, XML/Soap Service, JSON feed, etc. That way you'd not be likely to violate any T.O.S. that they might already have in place.... Quote Link to comment https://forums.phpfreaks.com/topic/283897-getting-content-from-another-website/#findComment-1458284 Share on other sites More sharing options...
QuickOldCar Posted November 14, 2013 Share Posted November 14, 2013 I think just the uk bbc has feeds http://www.bbc.co.uk/news/10628494 Quote Link to comment https://forums.phpfreaks.com/topic/283897-getting-content-from-another-website/#findComment-1458291 Share on other sites More sharing options...
rasmushs Posted November 14, 2013 Author Share Posted November 14, 2013 I would prefer to go strictly by code. Isn't that possible? Quote Link to comment https://forums.phpfreaks.com/topic/283897-getting-content-from-another-website/#findComment-1458295 Share on other sites More sharing options...
.josh Posted November 14, 2013 Share Posted November 14, 2013 Yes it's possible. It can possibly be as simple as using file_get_contents but may be difficult and require some advanced cURL trickery. The important thing though is making sure you do not violate their ToS. Quote Link to comment https://forums.phpfreaks.com/topic/283897-getting-content-from-another-website/#findComment-1458296 Share on other sites More sharing options...
rasmushs Posted November 18, 2013 Author Share Posted November 18, 2013 Sounds great. Any links to any tutorials? What do you mean by: "violate their ToS"? Quote Link to comment https://forums.phpfreaks.com/topic/283897-getting-content-from-another-website/#findComment-1458806 Share on other sites More sharing options...
rasmushs Posted November 18, 2013 Author Share Posted November 18, 2013 For people finding this thread in the future: This worked for me.. <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://olsensanonymous.blogspot.dk/'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);curl_setopt($ch, CURLOPT_TIMEOUT, 300); $data = curl_exec($ch); file_put_contents("text trendspider.txt", $data); curl_close($ch);?>Then you just have to sort out the parts of the code that you want to use Quote Link to comment https://forums.phpfreaks.com/topic/283897-getting-content-from-another-website/#findComment-1458807 Share on other sites More sharing options...
dalecosp Posted November 18, 2013 Share Posted November 18, 2013 Sounds great. Any links to any tutorials? What do you mean by: "violate their ToS"? As we said above, "ToS" is "Terms of Service". Blogspot is a Google property. It would be a good idea to have your legal department, attorney, or supervisor understand what you are doing, and then read this. Quote Link to comment https://forums.phpfreaks.com/topic/283897-getting-content-from-another-website/#findComment-1458812 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.