Package engine.zulu

Source Code of engine.zulu.ZuluSpider

package engine.zulu;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import test.old.SignalCreator;
import test.old.TableParser;
import test.old.TraderInfo;

/**
* 1. �ΰ��� ũ�ҵ���̹��� ����
* 2. ���
* 3. ��ϵ� Ʈ���̴��� ���¿����� ��� �����´�.
* 4. �����Ͽ�Trader.csv�� �����Ѵ�.
*
*  MQL5
*  1. Trader.csv�� �д´�.
*  2. ���¿������� �ż� (�Ǵ� �ŵ�)�� mql���� ���� ��� ������ ū ������ û���Ѵ�.
*  3. ���¿������� �ż� (�Ǵ� �ŵ�)�� mql���� ���� ��� �ż��ֹ��� ���� ���ڸ� �����.
*  
*  2014/01/27 �ֹ��ð��� ���� ���� �����ϴ� ���� �߰� �ʿ�.
*
* @author park
*
*/


/**
* mql4 11216280/ede7mde
*
* IE
* ����� �̸�: DM861827

   ��й�ȣ: 3uo5y5ox
* @author park
*
*/
public class ZuluSpider {
  static String PATH = "C:\\logs\\";
  static String os = System.getProperty("os", "linux");
  static String browser = System.getProperty("browser", "chrome");
  static String path = System.getProperty("path", "C:\\logs\\");
  //static String traderInfoFilePath = PATH + "Trader.csv";
  private static final String initialUrl = "https://www.zulutrade.com/";
 
  private List<TraderInfo> traderList = new ArrayList<TraderInfo>();
   
  public static void main(String args[]) {
    while (true) {
      new ZuluSpider().run();
    }
  }
 
 
  public void run() {
   
    init();
   
    WebDriver driver = new ChromeDriver();
   
   
    login(driver);
   
    TableParser t = null;
   
    try {
      Thread.sleep(5000);
    } catch (InterruptedException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
   
    while (true) {
     
      try {
       
        //for (TraderInfo ti : traderList) {
                 
          //driver.get(ti.getUrl());
               
                driver.findElement(By.linkText("������")).click();

                Thread.sleep(5000);
               
          String s =  driver.findElement(By.id("table-body-positions")).getText();
         
                System.out.println(s);
               
          t = new TableParser(s);
         
          t.parse();
               
               
        //}
       

        SignalCreator sc = new SignalCreator(t.getZuluData());
        sc.createFile(path + "SIGNAL.CSV");
       
        driver.navigate().refresh();
        Thread.sleep(60000);
       
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
     
    }
   
    //driver.quit();
  }
 
  private void login(WebDriver driver) {
        driver.get(initialUrl);
        driver.findElement(By.id("login-trigger")).click();
        driver.findElement(By.id("login-username")).sendKeys("DM42218633");//
        driver.findElement(By.id("login-password")).sendKeys("e4k5gcu6");//
       
        driver.findElement(By.id("btn-login")).click();
   
  }


  private void init() {
    System.setProperty("webdriver.chrome.driver","C:\\Titanium\\Titanium1\\lib\\chromedriver.exe");

    //readTraderInfoFile();
  }


//  private void readTraderInfoFile() {
//
//    BufferedReader br = null;
//    String line = "";
//    String cvsSplitBy = ",";
//  
//    try {
//  
//      br = new BufferedReader(new FileReader(traderInfoFilePath));
//      while ((line = br.readLine()) != null) {
//        TraderInfo ti = new TraderInfo();
//        String[] dataArray = line.split(cvsSplitBy);
//        int importance = Integer.parseInt(dataArray[0]);
//        String traderName = dataArray[1];
//        String url = dataArray[2];
//       
//        ti.setImportance(importance);
//        ti.setTraderName(traderName);
//        ti.setUrl(url);
//        traderList.add(ti);
//      }
//  
//    } catch (FileNotFoundException e) {
//      e.printStackTrace();
//    } catch (IOException e) {
//      e.printStackTrace();
//    } finally {
//      if (br != null) {
//        try {
//          br.close();
//        } catch (IOException e) {
//          e.printStackTrace();
//        }
//      }
//    }
//  }

  public static void scrapSite(WebDriver driver) throws FileNotFoundException {       
        // this its form more than 05 minutes without return
        try {

            if(driver == null)
            {
              System.err.println("driver == null");
              System.exit(1);
            }
           
            String initialUrl = "https://www.zulutrade.com/";
            driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.HOURS);
            driver.manage().timeouts().setScriptTimeout(30, TimeUnit.HOURS);
            driver.get(initialUrl);
            //�α���
//            driver.findElement(By.id("login-trigger")).click();
//            driver.findElement(By.id("login-username")).sendKeys("DM472968");
//            driver.findElement(By.id("login-password")).sendKeys("un3n5g");
           
//            driver.findElement(By.id("btn-login")).click();
           
//            Thread.sleep(5000);
           
            driver.findElement(By.linkText("������")).click();

            Thread.sleep(5000);
           
            String s =  driver.findElement(By.id("table-body-positions")).getText();
            System.out.println(s);
        while (true) {

            TableParser t = new TableParser(s);
            t.parse();
            SignalCreator sc = new SignalCreator(t.getZuluData());
            sc.createFile(path + "SIGNAL.CSV");
           
            driver.navigate().refresh();
            Thread.sleep(60000);
           
        }
          

        } catch (Exception ex) {
            //ConsoleHelper.printMessage("ERRO_ex:" + ex.getMessage(), new Date());
          ex.printStackTrace();
          return;
        }
    }

}
TOP

Related Classes of engine.zulu.ZuluSpider

TOP
Copyright © 2018 www.massapi.com. 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.