最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java實(shí)現(xiàn)淘寶秒殺聚劃算搶購自動(dòng)提醒源碼

 更新時(shí)間:2020年09月29日 14:19:06   作者:Techzero  
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)淘寶秒殺聚劃算搶購自動(dòng)提醒源碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

說明

本實(shí)例能夠監(jiān)控聚劃算的搶購按鈕,在聚劃算整點(diǎn)聚的時(shí)間到達(dá)時(shí)自動(dòng)彈開頁面(URL自己定義)。

可以自定義監(jiān)控持續(xù)分鐘數(shù),同時(shí)還可以通過多線程加快刷新速度。

源碼

package com.itechzero.pricemonitor; 
 
import java.io.BufferedInputStream; 
import java.io.BufferedReader; 
import java.io.InputStream; 
import java.io.InputStreamReader; 
import java.io.OutputStreamWriter; 
import java.net.URI; 
import java.net.URL; 
import java.net.URLConnection; 
import java.text.SimpleDateFormat; 
import java.util.Date; 
 
/** 
 * PriceMonitor.java 
 * 
 * @author Techzero 
 * @Email techzero@163.com 
 * @Time 2014-5-21 下午1:24:30 
 */ 
class MyThread extends Thread { 
 public void run() { 
  try { 
   // 此處參數(shù)為監(jiān)控持續(xù)分鐘數(shù) 
   PriceMonitor.monitorButton(10); 
  } catch (Exception e) { 
   e.printStackTrace(); 
  } 
 } 
}; 
 
public class PriceMonitor { 
 // 監(jiān)控的商品URL 
 private static String URL = "http://detail.ju.taobao.com/home.htm?spm=608.2214381.3.1.AdPEjn&item_id=38260927591&id=10000002781939"; 
 
 // 監(jiān)視按鈕 
 public static void monitorButton(int lastMinute) { 
  int nowMinute = Integer.parseInt(new SimpleDateFormat("mm").format(new Date())); 
  int endMinute = Integer.parseInt(new SimpleDateFormat("mm").format(new Date())) + lastMinute; 
  while (nowMinute < endMinute) { 
   nowMinute = Integer.parseInt(new SimpleDateFormat("mm").format(new Date())); 
   String result[] = getCurrentButtonAndForm(URL, "gb2312").split(","); 
   // 當(dāng)前按鈕狀態(tài) 
   String currentButton = result[0]; 
   // 馬上搶 表單 
   //String form = result[1]; 
   String nowTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); 
   System.out.println(nowTime + " - 現(xiàn)在按鈕是 " + currentButton); 
 
   if (currentButton == "馬上搶" || currentButton.equals("馬上搶") || currentButton == "還有機(jī)會(huì)" || currentButton.equals("還有機(jī)會(huì)")) { 
    System.out.println("趕緊下單!"); 
    try { 
     java.awt.Desktop.getDesktop().browse(new URI(URL)); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    //doPost(form); 
    break; 
   } else if (currentButton == "賣光了" || currentButton.equals("賣光了") || currentButton.equals("已結(jié)束") || currentButton.equals("已結(jié)束")) { 
    System.out.println("下次再試吧!"); 
    break; 
   } else { 
    System.out.println("還沒開始呢,再等等吧!"); 
   } 
  } 
 } 
 
 // 獲取當(dāng)前按鈕狀態(tài) 
 public static String getCurrentButtonAndForm(String url, String encoding) { 
  if (url == null || "".equals(url.trim())) 
   return null; 
  String buttonState = ""; 
  StringBuffer content = new StringBuffer(); 
  boolean formFlag = false; 
  try { 
   // 新建URL對象 
   URL u = new URL(url); 
   InputStream is = new BufferedInputStream(u.openStream()); 
   InputStreamReader theHTML = new InputStreamReader(is, encoding != null ? encoding : "gb2312"); 
   BufferedReader br = new BufferedReader(theHTML); 
   String s = ""; 
   while ((s = br.readLine()) != null) { 
    if (s.indexOf("<input type=\"submit\" class=\"buyaction J_BuySubmit\" title=\"馬上搶\" value=\"馬上搶\"/>") != -1) { 
     buttonState = "馬上搶"; 
    } else if (s.indexOf("<a href=\"#\" class=\"extra notice J_BuyButtonSub\">開團(tuán)提醒</a>") != -1) { 
     buttonState = "開團(tuán)提醒"; 
    } else if (s.indexOf("<div class=\"main-box chance \">") != -1) { 
     buttonState = "還有機(jī)會(huì)"; 
    } else if (s.indexOf("<span class=\"out floatright\">賣光了...</span>") != -1) { 
     buttonState = "賣光了"; 
    } else if (s.indexOf("<span class=\"out floatright\">已結(jié)束...</span>") != -1) { 
     buttonState = "已結(jié)束"; 
    } 
    if (s.indexOf("<form class=\"J_BuySubForm\" data-ccb=\"0\" data-ques=\"0\" action") != -1) { 
     content.append(s + "\r\n"); 
     formFlag = true; 
    } 
    if (formFlag == true) { 
     if (s.indexOf("<input name=\'_tb_token_\' type=\'hidden\' value") != -1) { 
      content.append(s + "\r\n"); 
     } 
     if (s.indexOf("<input type=\"hidden\" name=\"_input_charset\" value") != -1) { 
      content.append(s + "\r\n"); 
     } 
     if (s.indexOf("<input type=\"hidden\" name=\"itemId\" value") != -1) { 
      content.append(s + "\r\n"); 
     } 
     if (s.indexOf("<input type=\"hidden\" name=\"id\" value") != -1) { 
      content.append(s + "\r\n"); 
     } 
     if (s.indexOf("<input type=\"hidden\" name=\"tgType\" value") != -1) { 
      content.append(s + "\r\n"); 
     } 
     if (s.indexOf("<input type=\"submit\" class=\"buyaction J_BuySubmit\"") != -1) { 
      content.append(s + "\r\n"); 
     } 
     if (s.indexOf("</form>") != -1) { 
      content.append(s + "\r\n"); 
     } 
    } 
    if (s.indexOf("<div class=\"time-banner\">") != -1) { 
     break; 
    } 
   } 
   br.close(); 
  } catch (Exception e) { 
   System.err.println(e); 
   return "Open URL Error"; 
  } 
  return buttonState + "," + content; 
 } 
 
 // 提交表單 
 public static String doPost(String form) { 
  StringBuffer content = new StringBuffer(); 
  try { 
   URLConnection connection = new URL(URL).openConnection(); 
   connection.setDoOutput(true); 
   OutputStreamWriter os = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); 
   os.write(form); 
   os.flush(); 
   os.close(); 
   InputStream is = connection.getInputStream(); 
   InputStreamReader theHTML = new InputStreamReader(is); 
   BufferedReader br = new BufferedReader(theHTML); 
   String s = ""; 
   while ((s = br.readLine()) != null) { 
    content.append(s + "\r\n"); 
   } 
  } catch (Exception e) { 
   e.printStackTrace(); 
  } 
  // 返回提交表單后返回的頁面內(nèi)容 
  return content.toString(); 
 } 
  
 // 登錄 
 public static void doLogin(String username, String password) { 
  String form = "<form id=\"J_StaticForm\" action=\"https://login.taobao.com/member/login.jhtml\" method=\"post\" autocomplete=\"on\"><input type=\"text\" name=\"TPL_username\" id=\"TPL_username_1\" value=\"" + username + "\"><input type=\"password\" name=\"TPL_password\" id=\"TPL_password_1\" value=\"" + password + "\"><input type=\"hidden\" id=\"J_TPL_redirect_url\" name=\"TPL_redirect_url\" value=\"http://www.taobao.com/?spm=a2107.1.1000340.1.AL2Mpn\"><button type=\"submit\" id=\"J_SubmitStatic\">登 錄</button></form>"; 
  doPost(form); 
 } 
 
 public static void main(String[] args) { 
  //doLogin(); 
  // new MyThread().start(); 
  // new MyThread().start(); 
  // new MyThread().start(); 
  // new MyThread().start(); 
  // new MyThread().start(); 
  // new MyThread().start(); 
  // new MyThread().start(); 
  new MyThread().start(); 
 } 
} 

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 關(guān)于Spring?Validation數(shù)據(jù)校檢的使用流程分析

    關(guān)于Spring?Validation數(shù)據(jù)校檢的使用流程分析

    在實(shí)際項(xiàng)目中,對客戶端傳遞到服務(wù)端的參數(shù)進(jìn)行校驗(yàn)至關(guān)重要,SpringValidation提供了一種便捷的方式來實(shí)現(xiàn)這一需求,通過在POJO類的屬性上添加檢查注解,本文給大家介紹Spring?Validation數(shù)據(jù)校檢的使用流程,感興趣的朋友一起看看吧
    2024-11-11
  • 詳解spring Boot Cli的配置和使用

    詳解spring Boot Cli的配置和使用

    本篇文章主要介紹了詳解spring Boot Cli的配置和使用,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-05-05
  • 一文徹底搞懂Java日期時(shí)間類詳解

    一文徹底搞懂Java日期時(shí)間類詳解

    這篇文章主要給大家介紹了關(guān)于Java日期時(shí)間類的相關(guān)資料,Calendar類的功能要比Date類強(qiáng)大很多,可以方便的進(jìn)行日期的計(jì)算,獲取日期中的信息時(shí)考慮了時(shí)區(qū)等問題,需要的朋友可以參考下
    2023-10-10
  • Feign Client超時(shí)時(shí)間設(shè)置不生效的解決方法

    Feign Client超時(shí)時(shí)間設(shè)置不生效的解決方法

    這篇文章主要為大家詳細(xì)介紹了Feign Client 超時(shí)時(shí)間設(shè)置不生效的原因與解決方法,具有一定的的參考價(jià)值,希望對大家有一定的幫助
    2025-04-04
  • Java中outer標(biāo)簽的用法實(shí)例代碼

    Java中outer標(biāo)簽的用法實(shí)例代碼

    這篇文章主要介紹了Java中outer標(biāo)簽的用法,在這里需要大家注意這里的outer并不是關(guān)鍵字,而僅僅是一個(gè)標(biāo)簽,本文結(jié)合實(shí)例代碼給大家詳細(xì)講解,需要的朋友可以參考下
    2023-01-01
  • Java處理Markdown格式轉(zhuǎn)換為Word文檔

    Java處理Markdown格式轉(zhuǎn)換為Word文檔

    這篇文章主要為大家詳細(xì)介紹了如何使用Java實(shí)現(xiàn)處理Markdown格式轉(zhuǎn)換為Word文檔,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以參考一下
    2025-03-03
  • Maven配置單倉庫與多倉庫的實(shí)現(xiàn)(Nexus)

    Maven配置單倉庫與多倉庫的實(shí)現(xiàn)(Nexus)

    本文主要介紹了Maven配置單倉庫與多倉庫的實(shí)現(xiàn)(Nexus),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-01-01
  • Java常用字符串工具類 字符串智能截取(3)

    Java常用字符串工具類 字符串智能截?。?)

    這篇文章主要為大家詳細(xì)介紹了Java常用字符串工具類,字符串的智能截取,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • 基于SpringBoot實(shí)現(xiàn)Web應(yīng)用的登錄與退出功能

    基于SpringBoot實(shí)現(xiàn)Web應(yīng)用的登錄與退出功能

    登錄與退出功能作為 Web 應(yīng)用中的基礎(chǔ)且重要的組成部分,直接關(guān)系到用戶的安全和隱私保護(hù),所以本文給大家介紹了基于SpringBoot實(shí)現(xiàn)Web應(yīng)用的登錄與退出功能,文中有詳細(xì)的代碼供大家參考,需要的朋友可以參考下
    2024-04-04
  • struts2通過action返回json對象

    struts2通過action返回json對象

    struts2通過action返回json對象其實(shí)很簡單的,首先我們需要引入jar包,然后在寫一個(gè)簡單的action就好了,接下來通過本文給大家介紹struts2通過action返回json對象的方法,感興趣的朋友一起看看吧
    2016-09-09

最新評(píng)論

城步| 内丘县| 东乌珠穆沁旗| 大名县| 砚山县| 保定市| 南漳县| 九江市| 洛阳市| 稷山县| 林芝县| 扶绥县| 紫金县| 伊春市| 岚皋县| 资中县| 彰化市| 岗巴县| 大新县| 栾川县| 新乐市| 婺源县| 马尔康县| 安阳市| 南皮县| 宾川县| 盖州市| 镇康县| 贞丰县| 丹凤县| 平凉市| 太康县| 宜良县| 陆丰市| 大新县| 叙永县| 中牟县| 天长市| 昌乐县| 化州市| 北碚区|