package test;

import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;

import com.zhsoft88.commons.Seaflower;
import com.zhsoft88.commons.Seaflower.SeaflowerConf;
import com.zhsoft88.commons.Seaflower.SeaflowerResult;

public class TestSeaflower3Cont {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		Seaflower sf = new Seaflower();
		{
			SeaflowerConf conf = new SeaflowerConf();
			conf.setContinue(true);
			conf.setNodata(true);
			conf.setWaitTime(10);
			conf.setUrl("http://www.gap.com/browse/product.do?cid=8793&vid=1&pid=655053");
			sf.crawl(conf);
		}
		for (char c='0';c<='4'; c++)
		{
			SeaflowerConf conf = new SeaflowerConf();
			conf.setContinue(c!='4');
			conf.setExec("document.getElementById('colorSwatch_"+c+"').onclick()");
			SeaflowerResult result = sf.crawl(conf);
			Document doc = DocumentHelper.parseText(result.getContents());
			Attribute a = (Attribute)doc.selectSingleNode("//img[@id='dragImg']/@src");
			System.out.println(a.getValue());
		}
	}

}
