Package com.crawl.model

Examples of com.crawl.model.CrawlResultPackage


           
            // Get items list
            Document document = Jsoup.connect(inputSearchUrl).get();
            Elements rows = document.select("p.row");
            for(Element row : rows) {
                CrawlResultPackage myTempCrawlResultPackage= new CrawlResultPackage();
                myTempCrawlResultPackage.setLine(row.html());
                // get price
                myTempCrawlResultPackage.setPriceOfItem(getPriceFromString(row.select("span.price").text()));
                // Get item and url
                myTempCrawlResultPackage.setItem(row.select("span.pl a").text());
                myTempCrawlResultPackage.setUrl(row.select("span.pl a").attr("abs:href"));
                // Get location
                myTempCrawlResultPackage.setLocations(getLocationsFromString(row.select("small").text()));
                aReturnColl.add(myTempCrawlResultPackage);
            }
        } catch (MalformedURLException mue) {
            mue.printStackTrace();
        } catch (IOException ioe) {
View Full Code Here


    public void test_comparator3() {
        logger.debug("Test comparator...");
       
        List<CrawlResultPackage> aCrawlResultPackage=new ArrayList<CrawlResultPackage>();
       
        CrawlResultPackage aCrawlResultPackage1=new CrawlResultPackage();
        aCrawlResultPackage1.setPriceOfItem(1000);
        aCrawlResultPackage.add(aCrawlResultPackage1);

        CrawlResultPackage aCrawlResultPackage2=new CrawlResultPackage();
        aCrawlResultPackage2.setPriceOfItem(1);
        aCrawlResultPackage.add(aCrawlResultPackage2);

        CrawlResultPackageComparator aCrawlResultPackageComparator=new CrawlResultPackageComparator();
        Collections.sort(aCrawlResultPackage, aCrawlResultPackageComparator);
       
View Full Code Here

    public void test_comparator4() {
        logger.debug("Test comparator...4");
       
        List<CrawlResultPackage> aCrawlResultPackage=new ArrayList<CrawlResultPackage>();
       
        CrawlResultPackage aCrawlResultPackage1=new CrawlResultPackage();
        aCrawlResultPackage1.setPriceOfItem(1000);
        aCrawlResultPackage.add(aCrawlResultPackage1);

        CrawlResultPackage aCrawlResultPackage2=new CrawlResultPackage();
        aCrawlResultPackage2.setPriceOfItem(1);
        aCrawlResultPackage.add(aCrawlResultPackage2);
       
        assertTrue(aCrawlResultPackage.size() == 2);
       
        CrawlResultPackageComparator aCrawlResultPackageComparator=new CrawlResultPackageComparator();
        Collections.sort(aCrawlResultPackage, aCrawlResultPackageComparator);       
       
        Iterator<CrawlResultPackage> aIt=aCrawlResultPackage.iterator();
       
        CrawlResultPackage aCrawlResultPackageOne=aIt.next();
        assertTrue(aCrawlResultPackageOne.getPriceOfItem() == 1);

        CrawlResultPackage aCrawlResultPackageTwo=aIt.next();
        assertTrue(aCrawlResultPackageTwo.getPriceOfItem() == 1000);
    }
View Full Code Here

    public void test_collectionAndPrice() {
        logger.debug("Test collection and price");
       
        List<CrawlResultPackage> aCrawlResultPackage=new ArrayList<CrawlResultPackage>();
       
        CrawlResultPackage aCrawlResultPackage1=new CrawlResultPackage();
        aCrawlResultPackage1.setPriceOfItem(1000);
        aCrawlResultPackage.add(aCrawlResultPackage1);

        CrawlResultPackage aCrawlResultPackage2=new CrawlResultPackage();
        aCrawlResultPackage2.setPriceOfItem(1);
        aCrawlResultPackage.add(aCrawlResultPackage2);
       
        assertTrue(aCrawlResultPackage.size() == 2);
       
        Iterator<CrawlResultPackage> aIt=aCrawlResultPackage.iterator();
       
        CrawlResultPackage aCrawlResultPackageOne=aIt.next();
        assertTrue(aCrawlResultPackageOne.getPriceOfItem() == 1000);

        CrawlResultPackage aCrawlResultPackageTwo=aIt.next();
        assertTrue(aCrawlResultPackageTwo.getPriceOfItem() == 1);
    }   
View Full Code Here

    public void test_sort() {
        logger.debug("Test sort...");
       
        List<CrawlResultPackage> aCrawlResultPackage=new ArrayList<CrawlResultPackage>();
       
        CrawlResultPackage aCrawlResultPackage1=new CrawlResultPackage();
        aCrawlResultPackage1.setPriceOfItem(1000);
        aCrawlResultPackage.add(aCrawlResultPackage1);

        CrawlResultPackage aCrawlResultPackage2=new CrawlResultPackage();
        aCrawlResultPackage2.setPriceOfItem(1);
        aCrawlResultPackage.add(aCrawlResultPackage2);
       
        assertTrue(aCrawlResultPackage.size() == 2);
       
        Iterator<CrawlResultPackage> aIt=aCrawlResultPackage.iterator();
       
        CrawlResultPackage aCrawlResultPackageOne=aIt.next();
        assertTrue(aCrawlResultPackageOne.getPriceOfItem() == 1000);

        CrawlResultPackage aCrawlResultPackageTwo=aIt.next();
        assertTrue(aCrawlResultPackageTwo.getPriceOfItem() == 1);
    }
View Full Code Here

            int inputToPrice,
            int inputSteps){
        Collection<CrawlResultPackage> aRetColl=new ArrayList<CrawlResultPackage>();
       
        for (int i=inputFromPrice;i<inputToPrice;i=i+inputSteps){
            CrawlResultPackage aPack=new CrawlResultPackage();
            aPack.setItem("PC Laptop &amp; Macbook Repairs System Software &amp; Data Recovery Start from");
            aPack.setLine("<a href=\"http://sfbay.craigslist.org/sfc/syd/3377230486.html\">$29 - PC Laptop &amp; Macbook Repairs System Software &amp; Data Recovery Start from</a>");
            Collection<String> aStringColl=new ArrayList<String>();
            aStringColl.add("downtown");
            aStringColl.add("civic");
            aStringColl.add("van ness");
            aPack.setLocations(aStringColl);
            aPack.setPriceOfItem(i);
            aPack.setUrl("http://sfbay.craigslist.org/sfc/syd/3377230486.html")
            logger.debug(aPack.toString());
            aRetColl.add(aPack);
        }
       
        return aRetColl;
    }
View Full Code Here

        logger.debug("aPackArray="+aPackArray.length);
       
        Collection<CrawlResultPackage> aCrawlCollTemp2=new ArrayList<CrawlResultPackage>();
       
        for (int i=0+aInt10Percent;i<=aCrawlCollTemp.size()-aInt10Percent-1;i++){
            CrawlResultPackage aPack=(CrawlResultPackage)aPackArray[i];
            logger.debug("aPack="+aPack.getPriceOfItem());
            aCrawlCollTemp2.add(aPack);
        }
       
        logger.debug("aCrawlCollTemp2="+aCrawlCollTemp2.size());
       
        Object[] aPackArrayRet=aCrawlCollTemp2.toArray();
        Collection<CrawlResultPackage> aCrawlCollRet=new ArrayList<CrawlResultPackage>();
               
        // Get the 10 expensivest offers
        for (int i=0;i<=this.howManyOffersToReturn;i++){
            CrawlResultPackage aPack2=(CrawlResultPackage)aPackArrayRet[i];
            logger.debug(i+". aPack2="+aPack2.getPriceOfItem());
            aCrawlCollRet.add(aPack2);
        }
       
        logger.debug("aCrawlCollRet="+aCrawlCollRet.size());
        return aCrawlCollRet;
View Full Code Here

      logger.debug("aPackArray="+aPackArray.length);
     
      Collection<CrawlResultPackage> aCrawlCollTemp2=new ArrayList<CrawlResultPackage>();
     
      for (int i=0+aInt10Percent;i<=aCrawlCollTemp.size()-aInt10Percent-1;i++){
          CrawlResultPackage aPack=(CrawlResultPackage)aPackArray[i];
          logger.debug("aPack="+aPack.getPriceOfItem());
          aCrawlCollTemp2.add(aPack);
      }
     
      logger.debug("aCrawlCollTemp2="+aCrawlCollTemp2.size());
     
      Object[] aPackArrayRet=aCrawlCollTemp2.toArray();
     
      logger.info("aPackArrayRet.length="+aPackArrayRet.length);
     
      Collection<CrawlResultPackage> aCrawlCollRet=new ArrayList<CrawlResultPackage>();
     
      int littleEqual=aPackArrayRet.length-this.howManyOffersToReturn;
     
      // Check if it turn to minus and if yes set it to 0
      if (littleEqual<0){
          littleEqual=0;
      }
     
      logger.debug("aPackArrayRet.length="+aPackArrayRet.length);
      logger.debug(aPackArrayRet.length-1+">="+littleEqual);
     
      try {
          for (int i = littleEqual; i < aPackArrayRet.length; i++){
              logger.debug("ArrayLength="+aPackArrayRet.length+" ["+i+"]>="+littleEqual+"************************");
              CrawlResultPackage aPack2=(CrawlResultPackage)aPackArrayRet[i];
              logger.debug(i+". aPack2="+aPack2.getPriceOfItem());
              aCrawlCollRet.add(aPack2);
          }
      } catch (ArrayIndexOutOfBoundsException e){
          logger.fatal(e.toString());
          e.printStackTrace();
View Full Code Here

  @Test
  public void test_createCrawlResultPackages() {
    logger.debug("Create Crawler modell classes...");
   
    CrawlResultPackage d= new CrawlResultPackage();
   
    assertTrue(d != null);
  }
View Full Code Here

    @Test
    public void test_CrawlResultPackage_Price() {
        logger.debug("Test CrawlResultPackage...price");
       
        CrawlResultPackage d= new CrawlResultPackage();
        d.setPriceOfItem(1000);
       
        assertTrue(d.getPriceOfItem() == 1000);
    }
View Full Code Here

TOP

Related Classes of com.crawl.model.CrawlResultPackage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.