Pull data from other site

Discussion in 'Programming' started by dados, Jun 2, 2009.

  1. #1
    Can you please give me some advice for this problem, I do it site in CMS, I have boxes on site http://www.istoots.com and in this boxes must pull automatic information from this site http://www.dodtracker.com/ but only in couple boxes, can somebody help me to give me advice hove I can do this...

    Thanks.
     
    dados, Jun 2, 2009 IP
  2. tguillea

    tguillea Active Member

    Messages:
    229
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #2
    First of all, you will need to make sure your php.ini settings can be set to "allow URL" for fread() and fopen().

    Start out by trying to get the file contents (source code) of the page
    
    $file = "http://domain.com/filename.txt";
    $handle = fopen("$file", "r") or die("cannot read file!");
    $max = filesize($file);
    $filestring = fread($handle, $max);
    
    PHP:
    then go ahead and explode by <li> as this is what the site uses for the boxes.
    
    $boxes = explode('<li>',$filestring);
    //$boxes[1] = first deal, $boxes[2] = second deal, etc
    
    PHP:
    then from that you can get the url, title, and other specific information to reformat the boxes if you want. Otherwise $boxes[X] will just be their code.

    Hope that helps!
     
    tguillea, Jun 3, 2009 IP
  3. dados

    dados Greenhorn

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    I know that fopen is on but I can not find fread...

    The biggest problem s that I did no where I can put this php code, I am a not good in php...

    Can you please help me??????????????
     
    dados, Jun 3, 2009 IP
  4. tguillea

    tguillea Active Member

    Messages:
    229
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #4
    something like this... call the file index.php and try running it. Not sure what will happen but it should be close?

    I dont think there is an allow URL for fread(), only fopen() because fopen uses fread

    
    <?php
    $file = "http://domain.com/filename.txt";
    $handle = fopen("$file", "r") or die("cannot read file!");
    $max = filesize($file);
    $filestring = fread($handle, $max);
    $boxes = explode('<li>',$filestring);
    ?>
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Welcome to www.istoots.com</title>
    <meta name="description" content="Welcome to www.istoots.com - Powered by Elxis CMS (www.elxis.org)" />
    <meta name="keywords" content="open source, multilingual, free cms, table-less, xhtml valid, css, content managment, rtl compatible, elxis.org, adodb, elxis" />
    <meta name="Generator" content="Elxis - Copyright (C) 2006-2009 Elxis.org. All rights reserved." />
    <meta name="robots" content="index, follow" />
    <base href="http://www.istoots.com/" />
    <link href="http://www.istoots.com/includes/standard.css" rel="stylesheet" type="text/css" media="all" />
    <script type="text/javascript" src="http://www.istoots.com/administrator/includes/js/ajax_new.js"></script>
    <script type="text/javascript" src="http://www.istoots.com/includes/js/elxis.js"></script>
    
    <link rel="alternate" type="application/rss+xml" title="Elxis RSS feeds" href="http://www.istoots.com/cache/rss20-english.xml" />
    <link rel="shortcut icon" href="http://www.istoots.com/images/favicon.ico" />
    <link href="http://www.istoots.com/templates/istoots/css/template_css.css" rel="stylesheet" type="text/css" media="all" />
    </head>
    
    <body>
    <center>
    <div id="container">
    	<!-- begin main wrap top with site name -->
    	<div align="center"><div id="mainwraptop">
        	<div id="sitename">
            	<div align="right"><div id="sitenametext">
                <a href="http://www.istoots.com/" title="Welcome to www.istoots.com" >
    
    			Welcome to www.istoots.com			</a>
                </div></div>
    		</div>
    	</div></div>
        
        <!-- begin main wrap with 6 boxes and banner position -->
        <div align="center"><div id="mainwrap">
        	<div id="mainwrapbody">
            	<!-- begin wrap with banner position -->
    
                <div id="baner-position">  
                <div class="moduletable">
    <p style="text-align: center;"><img src="file:///C:/Documents%20and%20Settings/rayjr.yagelski/desktop/istoots.gif" alt="" width="468" height="60" /><a title="www.istoots.com" href="http://www.istoots.com" target="_blank"></a></p></div>
    <div class="moduletable">
    <table id="AutoNumber1" style="border: 0pt solid #111111; border-collapse: collapse; height: 10px;" border="0" cellspacing="0" cellpadding="0" width="492">
    <tbody>
    <tr>
    <td width="100%"></td>
    </tr>
    </tbody>
    </table>
    <h2 style="text-align: center;"><span style="color: #ff0000;"><strong><span class="font_lphotdeals">Todays Hottest Daily Deals:</span></strong></span></h2>
    <p style="text-align: center;">Choose a category, or just
    				<a class="font_lpbold" href="http://www.dodtracker.com/deals/">view them all!</a></p></div>
    
     	
                </div>
                <!-- begin wrap with text on page -->
                <div id="textpage">
                
    			</div>
                <!-- begin wrap with 6 boxes -->
                <div id="box-position">
                	<div id="box-position12">	
                    	<!-- boxes position 1-->
                    	<div id="box-position1">
    
                        	<div class="module-round">
                                                  
                        					<div class="module">
    				<div>
    					<div>
    						<div>
    <? echo $boxes[1]; ?>
    </div>
    
    					</div>
    				</div>
    			</div>
    			
                           
                        	</div>
                        </div>
                        <!-- boxes position 2-->
                        <div align="right"><div id="box-position2">
                        	<div class="module-round">                       
                        				<div class="module">
    
    				<div>
    					<div>
    						<div>
    <? echo $boxes[2]; ?>
    </div>
    					</div>
    				</div>
    
    			</div>
    		                      
                            </div>
                        </div></div>
                        <!-- This is important did not remove this spacer-->
                        <div id="exspacer"></div>
                	</div>
                    <div id="box-position34">
                    	<!-- boxes position 3-->
                    	<div id="box-position3">
    
                        	<div class="module-round">
                        				<div class="module">
    				<div>
    					<div>
    						<div>
    						<h3><a title="Wood" href="http://www.istoots.com">Tooliday</a></h3>
    <p><span style="font-size: 10pt; font-style: italic; font-weight: normal;">(sports gear, outdoor gear, clothing)</span></p>
    <hr />
    <table style="border: 0pt solid black; margin: 0px auto;" border="0" width="365">
    
    <tbody>
    <tr>
    <td class="info" style="padding: 0px; vertical-align: top;" colspan="2">
    <div style="width: 100%; background-color: #000000;"><a href="http://www.dodtracker.com/click/wmilitia/lpage-logo/" target="_dod_deal"><img style="margin: 0px auto; display: block;" src="http://img.dodtracker.com/logos/wmilitia/150x30.gif" alt="" width="150" height="30" /></a></div>
    </td>
    <td class="tdstruct" style="line-height: 100%; vertical-align: middle;" rowspan="5" width="125" height="125"><a href="http://www.dodtracker.com/click/wmilitia/lpage-pic/" target="_dod_deal"><img src="http://img.dodtracker.com/new/prod/wmilitia/226096/125x125.jpg" alt="" /></a></td>
    </tr>
    <tr>
    <td class="info" style="white-space: normal;" colspan="2"><a href="http://www.dodtracker.com/click/wmilitia/lpage-title/" target="_dod_deal"><span style="font-size: 10pt;">Analog Quantum Backpack</span></a></td>
    </tr>
    <tr>
    <td class="info tdstruct" style="width: 75px;">Price:</td>
    <td class="info tdstruct">$24.99 +  S/H									(<span style="color: #ff0000;"><span style="font-weight: bold;"><span>62% off</span></span></span>)</td>
    
    </tr>
    <tr>
    <td class="info" style="width: 75px;">Status:</td>
    <td class="info instock" style="font-weight: bold;"><span style="color: #99cc00;">IN STOCK</span></td>
    </tr>
    <tr>
    <td class="info" style="width: 75px;">Age:</td>
    <td class="info">
    <div class="timelow">20 min</div>
    </td>
    </tr>
    </tbody>
    </table>
    
    <p><a href="http://localhost/cwclaims"></a></p>						</div>
    					</div>
    				</div>
    			</div>
    		                        </div>
                        </div>
                        <!-- boxes position 4-->
                        <div align="right"><div id="box-position4">
                        	<div class="module-round">
    
                        				<div class="module">
    				<div>
    					<div>
    						<div>
    						<h3><a title="Wood" href="http://www.istoots.com">New Egg</a></h3>
    <p><span style="font-size: 10pt; font-style: italic; font-weight: normal;">(instruments, cds, dvds, toys, games)</span></p>
    <hr />
    <table style="border: 0pt solid black; margin: 0px auto;" border="0" width="365">
    <tbody>
    <tr>
    
    <td class="info" style="padding: 0px; vertical-align: top;" colspan="2">
    <div style="width: 100%; background-color: #333333;"><a href="http://www.dodtracker.com/click/doriginal/lpage-logo/" target="_dod_deal"><img style="margin: 0px auto; display: block;" src="http://img.dodtracker.com/logos/doriginal/150x30.gif" alt="" width="150" height="30" /></a></div>
    </td>
    <td class="tdstruct" style="line-height: 100%; vertical-align: middle;" rowspan="5" width="125" height="125"><a href="http://www.dodtracker.com/click/doriginal/lpage-pic/" target="_dod_deal"><img src="http://img.dodtracker.com/new/prod/doriginal/225968/125x125.jpg" alt="" /></a></td>
    </tr>
    <tr>
    <td class="info" style="white-space: normal;" colspan="2"><a href="http://www.dodtracker.com/click/doriginal/lpage-title/" target="_dod_deal"><span style="font-size: 10pt;">Reflections - 1</span></a></td>
    </tr>
    <tr>
    <td class="info tdstruct" style="width: 75px;">Price:</td>
    <td class="info tdstruct">$2300.00 +  S/H</td>
    </tr>
    <tr>
    <td class="info" style="width: 75px;">Status:</td>
    
    <td class="info instock" style="font-weight: bold;"><span style="color: #99cc00;">IN STOCK</span></td>
    </tr>
    <tr>
    <td class="info" style="width: 75px;">Age:</td>
    <td class="info">4h</td>
    </tr>
    </tbody>
    </table>
    <p><a href="http://localhost/cwclaims"></a></p>						</div>
    					</div>
    				</div>
    
    			</div>
    		                        </div>
                        </div></div>
                        <!-- This is important did not remove this spacer-->
                        <div id="eyspacer"></div>
                	</div>
                    <div id="box-position56">	
                    	<!-- boxes position 5-->
                    	<div id="box-position5">
    
                        	<div class="module-round">
                        				<div class="module">
    				<div>
    					<div>
    						<div>
    						<h3><a title="Wood" href="http://www.istoots.com">4imprint</a></h3>
    <p><span style="font-size: 10pt; font-style: italic; font-weight: normal;">(housewares, tools, jewelry, baby items, wine, cigars)</span></p>
    <hr />
    <table style="border: 0pt solid black; margin: 0px auto;" border="0" width="370">
    
    <tbody>
    <tr>
    <td class="info" style="padding: 0px; vertical-align: top;" colspan="2">
    <div style="width: 100%; background-color: #ffffff;"><a href="http://www.dodtracker.com/click/cshark/lpage-logo/" target="_dod_deal"><img style="margin: 0px auto; display: block;" src="http://img.dodtracker.com/logos/cshark/150x30.gif" alt="" width="150" height="30" /></a></div>
    </td>
    <td class="tdstruct" style="line-height: 100%; vertical-align: middle;" rowspan="5" width="125" height="125"><a href="http://www.dodtracker.com/click/cshark/lpage-pic/" target="_dod_deal"><img src="http://img.dodtracker.com/new/prod/cshark/225804/125x125.jpg" alt="" /></a></td>
    </tr>
    <tr>
    <td class="info" style="white-space: normal;" colspan="2"><a href="http://www.dodtracker.com/click/cshark/lpage-title/" target="_dod_deal"><span style="font-size: 10pt;">Fossil FS4303 Black IP Stainless Steel Black Dial Diamond Mens Watch</span></a></td>
    </tr>
    <tr>
    <td class="info tdstruct" style="width: 40px;">Price:</td>
    <td class="info tdstruct">$49.00+$5.00 S/H									(<span style="color: #ff0000;"><span style="font-weight: bold;">53% off</span></span>)</td>
    
    </tr>
    <tr>
    <td class="info" style="width: 40px;">Status:</td>
    <td class="info instock" style="font-weight: bold;"><span style="color: #99cc00;">IN STOCK</span></td>
    </tr>
    <tr>
    <td class="info" style="width: 40px;">Age:</td>
    <td class="info">8h</td>
    </tr>
    </tbody>
    </table>
    <p><a href="http://localhost/cwclaims"></a></p>						</div>
    
    					</div>
    				</div>
    			</div>
    		                        </div>
                        </div>
                        <!-- boxes position 6-->
                        <div align="right"><div id="box-position6">
                        	<div class="module-round">
                        				<div class="module">
    
    				<div>
    					<div>
    						<div>
    						<h3><a title="Wood" href="http://www.istoots.com">Custom</a></h3>
    <p><span style="font-size: 10pt; font-style: italic; font-weight: normal;">(other categories or sites selling across categories)</span></p>
    <hr />
    <table style="border: 0pt solid black; margin: 0px auto;" border="0" width="370">
    <tbody>
    <tr>
    <td class="info" style="padding: 0px; vertical-align: top;" colspan="2">
    <div style="width: 100%; background-color: #ffffff;"><a href="http://www.dodtracker.com/click/sneakadeal/lpage-logo/" target="_dod_deal"><img style="margin: 0px auto; display: block;" src="http://img.dodtracker.com/logos/sneakadeal/150x30.gif" alt="" width="150" height="30" /></a></div>
    
    </td>
    <td class="tdstruct" style="line-height: 100%; vertical-align: middle;" rowspan="5" width="125" height="125"><a href="http://www.dodtracker.com/click/sneakadeal/lpage-pic/" target="_dod_deal"><img src="http://img.dodtracker.com/new/prod/sneakadeal/225969/125x125.jpg" alt="" /></a></td>
    </tr>
    <tr>
    <td class="info" style="white-space: normal;" colspan="2"><a href="http://www.dodtracker.com/click/sneakadeal/lpage-title/" target="_dod_deal"><span style="font-size: 10pt;">The Poking Man Pen Stand</span></a></td>
    </tr>
    <tr>
    <td class="info tdstruct" style="width: 75px;">Price:</td>
    <td class="info tdstruct">$10.00 + $2.00 S/H</td>
    </tr>
    <tr>
    <td class="info" style="width: 75px;">Status:</td>
    <td class="info instock" style="font-weight: bold;"><span style="color: #99cc00;">50 LEFT</span></td>
    
    </tr>
    <tr>
    <td class="info" style="width: 75px;">Age:</td>
    <td class="info">4h</td>
    </tr>
    </tbody>
    </table>						</div>
    					</div>
    				</div>
    			</div>
    		                        </div>
    
                        </div></div>
                        <!-- This is important did not remove this spacer-->
                        <div id="espacer"></div>
                	</div>
                </div>
                
                <!-- begin wrap with banner position 2-->
                <div id="baner-position2">  
                <div class="moduletable">
    <p style="text-align: center;"><a title="www.istoots.com" href="http://www.istoots.com" target="_blank"><img title="www.istoots.com" src="http://www.istoots.com/images/banners/elxis-support.jpg" alt="www.istoots.com" width="130" height="140" /></a></p></div>
                 	
                </div>
    
                
            </div>
            
    	</div></div>
        
        <!-- begin main wrap with footer -->
        <div align="center"><div id="footerwrap">
            <div id="footer-position">Site Design by <a href="http://www.webdesign.loviribolov.org">DP Studio</a>
            - Copyright &copy; 2009 DP Studio. All Rights Reserved.
            </div>
    
        </div></div>
    
    </div>
    </center>
    </body>
    </html>
    
    PHP:
     
    tguillea, Jun 3, 2009 IP
  5. dados

    dados Greenhorn

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    Can you please tell me what I need to put in this $file = "http://domain.com/filename.txt"; what filename.txt? And domain.com is my domain or domain from I need content?
     
    dados, Jun 3, 2009 IP
  6. tguillea

    tguillea Active Member

    Messages:
    229
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #6
    put in "http://www.dodtracker.com/" as that is the the one you want to pull the data from, correct?
     
    tguillea, Jun 3, 2009 IP