dcsimg
www.webdeveloper.com
Results 1 to 11 of 11

Thread: Pull data from one website to another

  1. #1
    Join Date
    Feb 2016
    Posts
    2

    Pull data from one website to another

    I'm not an advanced developer so excuse my ignorance on this topic. There is a page on a league wide website that publishes updated league standings each day that we would also like to display on our website (in our style/format of course). The website that has the data says they don't have a way to embed the data on our website and they don't offer any sort of widget, according to the support rep I spoke with.

    Is there a way to pull the data from their website to display on ours without their involvement? Here is the page with the data we'd like to display- American Association - standings | Pointstreak Sports Technologies

    Thanks

    **if this belongs in a different thread I apologize**

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,223
    Your link isn't working. This is possible though. You can use something like PHP to grab the content from the external site, then parse the HTML and display the standings table.
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    3,840
    Use an iframe but also ensure that you obtain republishing rights / permissions from the site authors.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  4. #4
    Join Date
    Feb 2016
    Posts
    2

  5. #5
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,223
    Here's a way to grab the table using PHP. You can then use CSS to style it however you want:

    Code:
    <?php
    	$url = 'http://www.pointstreak.com/baseball/standings.html?leagueid=193&amp;seasonid=30016';
    	$page = file_get_contents($url);
    	$page = mb_convert_encoding($page, 'utf-8', mb_detect_encoding($page));
    	$page = mb_convert_encoding($page, 'html-entities', 'utf-8'); 
    	$dom = new DOMDocument();
    	libxml_use_internal_errors(true);
    	$dom->loadHTML($page);
    	libxml_use_internal_errors(false);
    	$contentSection = $dom->getElementById('psbb_standings');
    	$pageContent = $dom->saveHTML($contentSection);
    	echo $pageContent;	
    ?>
    Please note, you definitely should get permission of the site owner since your taking the content directly from their page. Also, If they make any changes to the page, it may cause this method to stop working. This is very "hacky." An API of some type would be preferred.
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  6. #6
    Join Date
    Feb 2016
    Posts
    43
    Quote Originally Posted by cbVision View Post
    Here's a way to grab the table using PHP. You can then use CSS to style it however you want:

    Code:
    <?php
    	$url = 'http://www.pointstreak.com/baseball/standings.html?leagueid=193&seasonid=30016';
    	$page = file_get_contents($url);
    	$page = mb_convert_encoding($page, 'utf-8', mb_detect_encoding($page));
    	$page = mb_convert_encoding($page, 'html-entities', 'utf-8'); 
    	$dom = new DOMDocument();
    	libxml_use_internal_errors(true);
    	$dom->loadHTML($page);
    	libxml_use_internal_errors(false);
    	$contentSection = $dom->getElementById('psbb_standings');
    	$pageContent = $dom->saveHTML($contentSection);
    	echo $pageContent;	
    ?>
    Please note, you definitely should get permission of the site owner since your taking the content directly from their page. Also, If they make any changes to the page, it may cause this method to stop working. This is very "hacky." An API of some type would be preferred.

    Hello,
    I like your script and like to use it on my website i have created new publishing site where various newspaper news is publishing but after using your script my home page design is changed automatically. is their any solution about it. please.

  7. #7
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    3,840
    Quote Originally Posted by raselmd View Post
    Hello,
    I like your script and like to use it on my website i have created new publishing site where various newspaper news is publishing but after using your script my home page design is changed automatically. is their any solution about it. please.
    Always look for RSS feeds and take the data from the users site in that manner for PERSONAL USE but if you wish to republish anything, you must ask the site or data owners permission, especially those of news agencies, they can get a bit funny over who they allow to republish and there may be a licence agreement and fees involved... To publish without any agreement can lead to problems and legal issues because you would be stealing data that does not belong to you.

    People treat the internet like its the new frontier and wild west of digital stuff when its not and copyright, copyleft and trademarks still apply. Be sensible, be honest, above all else, observe others copyrights and ask.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  8. #8
    Join Date
    Feb 2016
    Posts
    1
    Use <iframe src="http://www.sourcesite.com/" id="your-id" scrolling="no"></iframe>

  9. #9
    Join Date
    Jan 2016
    Posts
    4
    You'll have to do it manually. You may be able to write a script to help you with this but if the site changes you will have to adapt it accordingly. You can do it by sending an HTTP request to the other website and process the reply.
    In Javascript you can use [Ajax to send your request and POSt/GET data.

  10. #10
    Join Date
    Jan 2016
    Posts
    227
    Ask permission from them first then ask if you can have an access to their database or use their API's to pull contents from their site to yours.

  11. #11
    Join Date
    Mar 2012
    Posts
    3,635
    Using an IFrame is the easiest way to display info from another site, though there are two factors you should consider:

    1. As others have said: DO NOT BREACH COPYRIGHT. Get permission to republish their info.

    2. One problem with IFrames is that the target web page is live. It is not always appropriate, but one way you can overcome this is by overlaying the IFrame with a transparent GIF image.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles