⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resumesend.java

📁 用JAVA语言实现JOB HUNTER的功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package jobhunter;import java.net.*;import java.io.*;import java.util.*;import javax.mail.*;import javax.mail.internet.*;import javax.activation.*;public class ResumeSend {  public ResumeSend(int size) {    this.keyQue = new Queue(size);  }  private String[] bakS = new String[]{".cn",".com.cn",".com",".net.cn",".gov.cn",".edu.cn",".net",".gov",".edu",".ac",".info",".jp",".hk",".tw",".uk"};  public static Queue keyQue;  public static int threads = 0;  public static void main(String[] args) throws Exception {    ResumeSend rssd = new ResumeSend(1000000);    File f = new File("emailsbak");    boolean onlyBak = false;    if (f.exists()) {      synchronized (f) {        System.out.print("Checking Backup Emails....");        try {          RandomAccessFile raf = new RandomAccessFile("emailsbak", "r");          String emLine;          while ( (emLine = raf.readLine()) != null) {            rssd.keyQue.enqueue(emLine);          }        }        catch (Exception e) {          e.printStackTrace();        }        System.out.println("BackFile Get " + rssd.keyQue.size() + " Emails.");        f.deleteOnExit(); //how to delete timely???      }      onlyBak = true;      if (rssd.keyQue.size() > 0) {        System.out.println("Are you want to send only back emails?[Y/n]:");        BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));        String answ = bin.readLine();        if (answ.toLowerCase().equals("n")) {          onlyBak = false;        }      }    } //end exists    if (!onlyBak) {      System.out.println("Begin Collecting Email....");      for(int i=0;i<args.length;i++){          int loc = Integer.parseInt(args[i]);          switch (loc) {            case 5: {              try{                rssd.chinahr_job_search(5); //软件,北京                System.out.println("ChinaHr 北京搜索成功!");                System.out.println("Now Emails: "+keyQue.size());              }catch(Exception e){                System.out.println("ChinaHr 北京搜索失败!");                e.printStackTrace(System.out);              }              break;            }            case 115: {              try{                rssd.chinahr_job_search(115); //软件,上海                System.out.println("ChinaHr 上海搜索成功!");                System.out.println("Now Emails: "+keyQue.size());              }catch(Exception e){                System.out.println("ChinaHr 上海搜索失败!");                e.printStackTrace(System.out);              }              break;            }            case 125: {              try{                rssd.chinahr_job_search(125); //软件,深圳                System.out.println("ChinaHr 深圳搜索成功!");                System.out.println("Now Emails: "+keyQue.size());              }catch(Exception e){                System.out.println("ChinaHr 深圳搜索失败!");                e.printStackTrace(System.out);              }              break;            }            case 100: {              try{                rssd.w51job_search("0100"); //软件 北京                System.out.println("51job 北京搜索成功!");                System.out.println("Now Emails: "+keyQue.size());              }catch(Exception e){                System.out.println("51job 北京搜索失败!");                e.printStackTrace(System.out);              }              break;            }            case 200: {              try{                rssd.w51job_search("0200"); //软件,上海                System.out.println("51job 上海搜索成功!");                System.out.println("Now Emails: "+keyQue.size());              }catch(Exception e){                System.out.println("51job 上海搜索失败!");                e.printStackTrace(System.out);              }              break;            }            case 400: {              try{                rssd.w51job_search("0400"); //软件,深圳                System.out.println("51job 深圳搜索成功!");                System.out.println("Now Emails: "+keyQue.size());              }catch(Exception e){                System.out.println("51job 深圳搜索失败!");                e.printStackTrace(System.out);              }              break;            }            case 1: {              try{                rssd.zhaopin_job_search(); //智联招聘网,北京,上海,深圳                System.out.println("智联招聘网 北京、上海、深圳搜索成功!");                System.out.println("Now Emails: "+keyQue.size());              }catch(Exception e){                System.out.println("5智联招聘网 北京、上海、深圳搜索失败!");                e.printStackTrace(System.out);              }              break;            }          } //switch        }//end for    }//end if    System.out.println("GET " + keyQue.size() + " EMAILS! Now Sending...");    SendThread sendT = new SendThread(10, 30);//每次最多连续发15封    sendT.run();  }  public void chinahr_job_search(int loc) throws Exception{    String baseUrl = "http://searchjob.chinahr.com/";    String head = "GET /jobsearch.asp?page=";    String body ="&mid=&order=0 HTTP/1.1"+  // /jobsearch.asp HTTP/1.1"+    "\r\n"+    "Accept-Language: zh-cn"+    "\r\n"+    "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*"+    "\r\n"+    "Host: searchjob.chinahr.com"+    "\r\n"+    "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.1))"+    "\r\n"+    "Connection: Close"+    "\r\n"+    "Cache-Control: no-cache"+    "\r\n"+    "Cookie: SrchJob=page=";    String cook ="&where=+FROM+searchjob++WHERE++and+occ%5Fid+%3D+601+and+job%5Fid+in+%28Select+job%5Fid+From+searchjobloc+Where+searchjobloc%2Ejob%5Fid+%3D+searchjob%2Ejob%5Fid++and+loc%5Fid+in+%28"+loc+"%29%29+and+job%5Ftitle+like+%27%25%C8%ED%BC%FE%25%27+and+update%5Fdate+%3E%3D+DATEADD%28day%2C+%2D7%2C+getdate%28%29%29+; JobAgent="+    "\r\n"+    "\r\n";    int str_p=1;    int end_p=2;    while(str_p<end_p)    {      Socket sk1 = new Socket("211.100.5.249",80);      BufferedOutputStream os = new BufferedOutputStream(sk1.getOutputStream());      HTTPInputStream is = new HTTPInputStream(sk1.getInputStream());      BufferedReader reader = new BufferedReader(new InputStreamReader(is));      os.write( (head+str_p+body+(str_p-1)+cook).getBytes());      os.flush();      String temp_line,line;      int j_p = 0;      int u_p = 0;      while ( (temp_line = reader.readLine()) != null) {       // System.out.println(temp_line);        //<A HREF="jobsearch.asp?page=6&mid=&order=0">        line = temp_line;        while( (u_p = line.indexOf("jobsearch.asp?page=")) > 0) {          String s1 = line.substring(u_p + 19);          line = s1;          int p_p = s1.indexOf("&");          if ( p_p > 100) {            continue;          }          String sPg = s1.substring(0, p_p);          int newP = (new Integer(sPg)).intValue();          if (newP < end_p) {            continue;          }          end_p = newP+1;        }        while ( (j_p = line.indexOf("Javascript:view(")) > 0) {          //Javascript:view('22203241092220128201','2002-5-13')          String s1 = line.substring(j_p + 17);          line =s1;          int com = s1.indexOf(",");          int rk = s1.indexOf(")");          String lNum = s1.substring(0, com - 1);          String dAte = s1.substring(com + 2, rk - 1);          int fH = dAte.lastIndexOf("-");          String YM = dAte.substring(0, fH);          String DY = dAte.substring(fH + 1);          String emUrl = baseUrl + "jobs/" + YM + "/" + DY + "/" + lNum +              ".htm";          try{            URL_email_search(emUrl);          }catch(Exception e){            System.out.println(emUrl+" Failed!");            e.printStackTrace(System.out);          }        }      }//end while      str_p++;    }  }  public void URL_email_search(String sUrl) throws Exception{    final String fUrl = sUrl;    Thread emsearch = new Thread(){      public void run(){        try {          ResumeSend.threads++;          URL url = new URL(fUrl);          BufferedReader reader = null;          boolean tryCon = true;          while(tryCon){            try{              HttpURLConnection urlc = (HttpURLConnection) url.openConnection();              reader = new BufferedReader(                  new InputStreamReader(urlc.getInputStream()));              tryCon = false;            }catch(Exception e){              int trys=1+(int)(10*Math.random());              tryCon = true;              e.printStackTrace(System.out);              System.out.println("Connect Failed! Let us wait "+trys+" minutes for "+fUrl+" again!");              this.sleep(1000*60*trys);            }          }          String temp_line, line;          int m_p = 0;          while ( (temp_line = reader.readLine()) != null) {            line = temp_line;            while ( (m_p = line.indexOf("mailto:")) > 0) {              String s1 = line.substring(m_p + 7);              line = s1;              int ed1 = s1.indexOf("?");              int ed2 = s1.indexOf(">");              int ed3 = ed1 < 0 ? ed2 :                  (ed2 < 0 ? ed1 : ( (ed1 < ed2) ? ed1 : ed2));              if (ed3 < 1)                ed3 = Math.min(40, s1.length());              String lem = s1.substring(0, ed3).toLowerCase();              //int end = s1.indexOf("?");              int bak_p = 100;              int bak_i = 0;              for (int j = 0; j < bakS.length; j++) {                int tt = 0;                tt = lem.indexOf(bakS[j]);                if ( (tt > 0) && (tt < bak_p)) {                  bak_p = tt;                  bak_i = j;                }              }              String email;              if(bak_p<100){                email = lem.substring(0, bak_p) + bakS[bak_i];              }else{                email = lem.substring(0, ed3);              }              if(email.equals("suggestion@zhaopin.com.cn")) continue;              synchronized(keyQue){                keyQue.add(email);              }            }          }        }catch(Exception e){          e.printStackTrace(System.out);        }        ResumeSend.threads--;      }    };    emsearch.start();  }  private static final String safeCharList = "$-_.+!*'(),";  public static String decode(String s)  {      if (s.equals("")) return "";      int len = s.length();      StringBuffer buf = new StringBuffer();      for (int i = 0; i < len; i++) {          char c = s.charAt(i);          if (Character.isLetterOrDigit(c))              buf.append(c);          else if (c == '+')              buf.append(' ');          else if (safeCharList.indexOf(c) != -1)              buf.append(c);          else if (c == '%') {              if (i >= len - 2) {                      return null;              } else {                  char[] hexChars = new char[2];                  hexChars[0] = s.charAt(++i);                  hexChars[1] = s.charAt(++i);                  String hexval = new String(hexChars);                  try {                      long read = hexToLong(hexval);                      if (read == 0)                          return null;                      buf.append(new Character((char) read));                  }                  catch (NumberFormatException nfe) {                      return null;                  }              }          }          else              buf.append(c);              // throw new URLEncodedFormatException(s);      }      return buf.toString();  }  public static final long hexToLong(String hex) throws NumberFormatException {      int len = hex.length();      if (len > 16)          throw new NumberFormatException();      long l = 0;      for (int i=0; i<len; i++) {          l<<=4;          int c = Character.digit(hex.charAt(i), 16);          if (c < 0)              throw new NumberFormatException();          l |= c;      }      return l;  }// Convenience class for reading client requests class HTTPInputStream extends FilterInputStream { public HTTPInputStream(InputStream in) {  super(in); } // Get a line public String readLine() throws IOException {  StringBuffer result=new StringBuffer();  boolean finished = false;  boolean cr = false;  do {   int ch = -1;   ch = read();   if(ch==-1) return result.toString();   result.append((char) ch);   if(cr && ch==10){    result.setLength(result.length()-2);    return result.toString();   }   if(ch==13) cr = true;   else cr=false;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -