Package com.jbidwatcher.util.html

Examples of com.jbidwatcher.util.html.JHTML


    //  If we failed to load, punt.  Treat it as success, but with a null form result.
    if (huc == null || (loadedPage = Http.net().receivePage(huc)) == null) {
      return new BidFormReturn(true, null, null, null);
    }

    JHTML htmlDocument = new JHTML(loadedPage);
    JHTML.Form bidForm = htmlDocument.getFormWithInput("key");

    //  eBay's testing a new form without the key...
    if(bidForm == null) {
      bidForm = htmlDocument.getFormWithInput("maxbid");
    }

    if (bidForm != null) {
      if (JConfig.debugging) inEntry.setLastStatus("Done loading bid request, got form...");
      return new BidFormReturn(true, bidForm, htmlDocument, loadedPage);
View Full Code Here


    }
    return new BidFormReturn(false, null, htmlDocument, loadedPage);
  }

  private void checkBidErrors(BidFormReturn inVal) throws BadBidException {
    JHTML htmlDocument = inVal.getDocument();
    String errMsg = htmlDocument.grep(mBidResultRegex);
    if(errMsg != null) {
      Matcher bidMatch = mFindBidResult.matcher(errMsg);
      bidMatch.find();
      String matched_error = bidMatch.group().toLowerCase();
      Integer result = getMatchedResult(matched_error);
      JConfig.log().dump2File("error-" + result + ".html", inVal.getBuffer());

      throw new BadBidException(matched_error, result);
    } else {
      String amount = htmlDocument.getNextContentAfterRegex("\\s*Enter\\s*");
      if (amount != null) {
        String orMore = htmlDocument.getNextContent();
        if (orMore != null && orMore.indexOf("or more") != -1) {
          JConfig.log().dump2File("error-" + ebayServer.BID_ERROR_TOO_LOW + ".html", inVal.getBuffer());
          throw new BadBidException("Enter " + amount + orMore, ebayServer.BID_ERROR_TOO_LOW);
        }
      }
View Full Code Here

    StringBuffer sb;

    try {
      CookieJar cj = mLogin.getNecessaryCookie(false);
      sb = cj.getPage(buyRequest, null, null);
      JHTML doBuy = new JHTML(sb);
      JHTML.Form buyForm = doBuy.getFormWithInput("uiid");

      if (buyForm != null) {
        buyForm.delInput("BIN_button");
        StringBuffer loadedPage = cj.getPage(buyForm.getAction(), buyForm.getFormData(), buyRequest);
        if (loadedPage == null) return AuctionServerInterface.BID_ERROR_CONNECTION;
View Full Code Here

    return handlePostBidBuyPage(cj, loadedPage, bidForm, inEntry);
  }

  private int handlePostBidBuyPage(CookieJar cj, StringBuffer loadedPage, JHTML.Form bidForm, AuctionEntry inEntry) {
    if(JConfig.debugging) inEntry.setLastStatus("Loading post-bid data.");
    JHTML htmlDocument = new JHTML(loadedPage);

    JHTML.Form continueForm = htmlDocument.getFormWithInput("firedFilterId");
    if(continueForm != null) {
      try {
        inEntry.setLastStatus("Trying to 'continue' to the bid result page.");
        String cgi = continueForm.getFormData();
        //  For some reason, the continue page represents the currency as
        //  separated from the amount with a '0xA0' character.  When encoding,
        //  this becomes...broken somehow, and adds an extra character, which
        //  does not work when bidding.
        cgi = cgi.replaceFirst("%[A-F][A-F0-9]%A0", "%A0");
        URLConnection huc = cj.connect(continueForm.getAction(), cgi, null, true, null);
        //  We failed to load, entirely.  Punt.
        if (huc == null) return AuctionServerInterface.BID_ERROR_CONNECTION;

        loadedPage = Http.net().receivePage(huc);
        //  We failed to load.  Punt.
        if (loadedPage == null) return AuctionServerInterface.BID_ERROR_CONNECTION;

        htmlDocument = new JHTML(loadedPage);
      } catch(Exception ignored) {
        return AuctionServerInterface.BID_ERROR_CONNECTION;
      }
    }

    String errMsg = htmlDocument.grep(mBidResultRegex);
    if (errMsg != null) {
      Matcher bidMatch = mFindBidResult.matcher(errMsg);
      bidMatch.find();
      String matched_error = bidMatch.group().toLowerCase();
      Integer bidResult = getMatchedResult(matched_error);
      JConfig.log().dump2File("error-" + bidResult + ".html", loadedPage);

      int result = 0;
      if (bidResult != null) {
        result = bidResult;
        if (result == ebayServer.BID_ERROR_BANNED ||
            result == ebayServer.BID_ERROR_WONT_SHIP ||
            result == ebayServer.BID_ERROR_REQUIREMENTS_NOT_MET) {
          inEntry.setErrorPage(loadedPage);
        }
      } else {
        String amount = htmlDocument.getNextContentAfterRegex("Enter");
        if (amount != null) {
          String orMore = htmlDocument.getNextContent();
          if (orMore != null && orMore.indexOf("or more") != -1) {
            result = ebayServer.BID_ERROR_TOO_LOW;
          }
        }
      }
View Full Code Here

    ListIterator li = pager.listIterator();

    while (li.hasNext()) {
      MQFactory.getConcrete("Swing").enqueue("Loading page " + li.nextIndex() + "/" + pager.size() + " from URL " + urlStr);

      JHTML htmlDocument = (JHTML) li.next();
      if (htmlDocument != null) {
        ItemResults rval = addAllItemsOnPage(htmlDocument, label, !((Searcher) searcher).shouldSkipDeleted());
        results += rval.getFirst().size();
      }
    }
View Full Code Here

    String myEBayURL = Externalized.getString("ebayServer.protocol") + Externalized.getString("ebayServer.sellingListHost") + Externalized.getString("ebayServer.V3file") +
        Externalized.getString("ebayServer.listedCGI") +
        Externalized.getString("ebayServer.sortOrderCGI") +
        Externalized.getString("ebayServer.userIdCGI") + userId;

    JHTML htmlDocument = new JHTML(myEBayURL, userCookie, mCleaner);

    if (htmlDocument.isLoaded()) {
      ItemResults rval = addAllItemsOnPage(htmlDocument, label, userId.equals(curUser));
      int count = rval.getFirst().size();

      MQFactory.getConcrete("Swing").enqueue("Loaded " + count + " new items for seller " + userId);
    } else {
View Full Code Here

    Map<String, String> collatedItems = new LinkedHashMap<String,String>();
    int newWatchCount = pullWatchingItems(curUser, userCookie, collatedItems);

    //  Get items you're watching
    rval = getAllItemsOnPage(new JHTML(Externalized.getString("ebayServer.oldWatching"), userCookie, mCleaner));
    collatedItems.putAll(rval.getLast());
    newWatchCount += rval.getFirst().size();
    int watchCount = collatedItems.size();
    newWatchCount = Math.min(newWatchCount, watchCount);
View Full Code Here

    boolean doneWatching = false;
    while (!doneWatching) {
      //  First load items that the user is watching (!)
      //    String watchingURL = Externalized.getString("ebayServer.watchingURL");
      String watchingURL = generateWatchedItemsURL(propertyKey, curUser, page);
      JHTML htmlDocument = getWatchedItemsPage(userCookie, watchingURL);
      String nextPage = null;
      if(htmlDocument.isLoaded()) {
        rval = getAllItemsOnPage(htmlDocument);
        collatedItems.putAll(rval.getLast());

        newWatchCount += rval.getFirst().size();

        nextPage = htmlDocument.getLinkForContent("Next");
        page++;
      }

      if (nextPage == null) doneWatching = true;
    }
View Full Code Here

  //  Now load items the user is bidding on...
  private ItemResults getBiddingOnItems(String userCookie) {
    String biddingURL = Externalized.getString("ebayServer.biddingURL");
    JConfig.log().logDebug("Loading page: " + biddingURL);

    JHTML htmlDocument = new JHTML(biddingURL, userCookie, mCleaner);
    return getAllItemsOnPage(htmlDocument);
  }
View Full Code Here

    JConfig.log().logDebug("URL: " + watchingURL);
    return watchingURL;
  }

  private JHTML getWatchedItemsPage(String userCookie, String watchingURL) {
    JHTML htmlDocument = new JHTML(watchingURL, userCookie, mCleaner);
    if(htmlDocument.isLoaded()) {
      if (htmlDocument.getTitle().equals("eBay Message")) {
        JConfig.log().logDebug("eBay is presenting an interstitial 'eBay Message' page!");
        JHTML.Form f = htmlDocument.getFormWithInput("MfcISAPICommand");
        if (f != null) {
          try {
            JConfig.log().logDebug("Navigating to the 'Continue to My eBay' page.");
            htmlDocument = new JHTML(f.getCGI(), userCookie, mCleaner);
          } catch (UnsupportedEncodingException uee) {
            JConfig.log().handleException("Failed to get the real My eBay page", uee);
          }
        }
      }
View Full Code Here

TOP

Related Classes of com.jbidwatcher.util.html.JHTML

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.