Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    problem extracting titles of ads from a website

    Hi guys..

    Im trying to learn php and im running into a few problems

    ok im trying to extract the titles of ads from this url

    http://www.carzone.ie/search/results...rows=30&page=1



    Here is the script that i am using to try and do this

    PHP Code:
    set_time_limit(-1);
       ob_implicit_flush(1);
         flush();
        ob_end_flush();
        
        
        $strURL = "";
        if(isset($_POST["crawlUrl"]))
            $strURL = $_POST["crawlUrl"];
            
        
        function getMatches($strMatch,$strContent) 
      {
            if(preg_match_all($strMatch,$strContent,$objMatches))
        {
                return $objMatches;
            }
            return "";
        }
    ?>
    <html>
    <head>
    <title>Project - Extracting Title of ads on www.carzone.ie  </title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
      <form name="frmExtract" method="post" action="">
    URL: <input name="crawlUrl" type="text" id="crawlUrl" size="50" value="<? print $strURL;?>" > 
         <input name="btnCrawl" type="submit" value="Crawl Data">
      </form>
      <br>
      <br>
    <?
        
    if($strURL != ""
      {
            
    $strListingUrl $strURL;
            while(
    true
        {    
                
    //Get the Content from the URL
                // file_get_contents — Reads entire file into a string
                
    $strContent file_get_contents($strListingUrl);

                
    //Expression to match the Link and Title
                
    $strListMatches '!<li class="vehicle-images" href="(.*)" title="(.*)"><span>(.*)</span></a></li>!isU';
                
    $objListMatches getMatches($strListMatches,$strContent);                       
        
             
    print_r($objListMatches[1]);
            
                if(
    $objListMatches == "" || count($objListMatches[1]) == 0
          {
                    print 
    "No List found or Invalid URL<br>";
                } 

            }
        }
    Can anybody tell me what im doing wrong please

    i keep getting "No List found or Invalid URL"

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    See, we've ran into this problem before. We could tell you how to do it but it would be breaking the terms and cons of that site...
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #3
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    This is for training purposes only...


  •  

    Posting Permissions

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