Subversion Repositories SmartDukaan

Rev

Rev 15527 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15527 Rev 18169
Line 39... Line 39...
39
		try{
39
		try{
40
			parseUrl();
40
			parseUrl();
41
			if (!checkCache()){
41
			if (!checkCache()){
42
				Document doc = Jsoup.connect(productUrl).get();
42
				Document doc = Jsoup.connect(productUrl).get();
43
				doc.outputSettings().charset("UTF-8");
43
				doc.outputSettings().charset("UTF-8");
-
 
44
				//System.out.println(doc);
44
				JSONArray jsonArray = new JSONArray(doc.getElementById("productAttributesJson").attr("value"));
45
				JSONArray jsonArray = new JSONArray(doc.getElementById("attributesJson").text());
-
 
46
				//System.out.println(jsonArray);
45
				for (int element=0; element<jsonArray.length();element++){
47
				for (int element=0; element<jsonArray.length();element++){
46
					try{
48
					try{
47
						JSONArray subAttributeArray = jsonArray.getJSONObject(element).getJSONArray("subAttributes");
49
						JSONArray subAttributeArray = jsonArray.getJSONObject(element).getJSONArray("subAttributes");
48
						for (int innerElement=0; innerElement< subAttributeArray.length(); innerElement++){
50
						for (int innerElement=0; innerElement< subAttributeArray.length(); innerElement++){
49
							if (supc.equalsIgnoreCase(subAttributeArray.getJSONObject(innerElement).getString("supc"))){
51
							if (supc.equalsIgnoreCase(subAttributeArray.getJSONObject(innerElement).getString("supc"))){
Line 72... Line 74...
72
		return getMsg();
74
		return getMsg();
73
	}
75
	}
74
 
76
 
75
	private UserMessagePojo getMsg(){
77
	private UserMessagePojo getMsg(){
76
		UserMessagePojo ump = new UserMessagePojo();
78
		UserMessagePojo ump = new UserMessagePojo();
-
 
79
		//System.out.println("color is "+color);
77
		if (color.isEmpty()){
80
		if (color==null || color.isEmpty()){
78
			ump.setResult(false);
81
			ump.setResult(false);
79
			ump.setMessage("");
82
			ump.setMessage("");
80
		}
83
		}
81
		else{
84
		else{
82
			ump.setResult(true);
85
			ump.setResult(true);
Line 123... Line 126...
123
				supcMap=(HashMap<String, String>)cacheValue;
126
				supcMap=(HashMap<String, String>)cacheValue;
124
				System.out.println("supc map "+supcMap);
127
				System.out.println("supc map "+supcMap);
125
				color = supcMap.get(supc);
128
				color = supcMap.get(supc);
126
				System.out.println("color "+color);
129
				System.out.println("color "+color);
127
				if (!(color==null || color.isEmpty())){
130
				if (!(color==null || color.isEmpty())){
-
 
131
					System.out.println("Returning true");
128
					return true;
132
					return true;
129
				}
133
				}
130
			}
134
			}
131
		}
135
		}
-
 
136
		System.out.println("Returning false");
132
		return false;
137
		return false;
133
	}
138
	}
134
 
139
 
135
	public void setUrl(String url) {
140
	public void setUrl(String url) {
136
		byte[] decoded = Base64.decode(url);
141
		byte[] decoded = Base64.decode(url);
Line 141... Line 146...
141
		return url;
146
		return url;
142
	}
147
	}
143
 
148
 
144
	public static void main(String[] args) throws URISyntaxException, IOException, JSONException{
149
	public static void main(String[] args) throws URISyntaxException, IOException, JSONException{
145
		SnapdealProductPageParserController s = new SnapdealProductPageParserController();
150
		SnapdealProductPageParserController s = new SnapdealProductPageParserController();
146
		//String url = "aHR0cDovL20uc25hcGRlYWwuY29tL3Byb2R1Y3QvaHRjLWRlc2lyZS01MjYtZy82ODE1MDk5MjQyNDg/c3VwYz1TREw1MjU0MDI1OTYmdXRtX3NvdXJjZT1hZmZfcHJvZyZ1dG1fY2FtcGFpZ249YWZ0cyZvZmZlcl9pZD0xNyZhZmZfaWQ9MzM1NTAmYWZmX3N1Yj1TSEEzMTQzMjEwODk3MA==";
151
//		//String url = "aHR0cDovL20uc25hcGRlYWwuY29tL3Byb2R1Y3QvaHRjLWRlc2lyZS01MjYtZy82ODE1MDk5MjQyNDg/c3VwYz1TREw1MjU0MDI1OTYmdXRtX3NvdXJjZT1hZmZfcHJvZyZ1dG1fY2FtcGFpZ249YWZ0cyZvZmZlcl9pZD0xNyZhZmZfaWQ9MzM1NTAmYWZmX3N1Yj1TSEEzMTQzMjEwODk3MA==";
147
		String url = "aHR0cDovL20uc25hcGRlYWwuY29tL3Byb2R1Y3QvaHRjLWRlc2lyZS02MjYtZy82NDAwMzA4NDA3MTU/c3VwYz1TREw5MzU5MzI1NzgmdXRtX3NvdXJjZT1hZmZfcHJvZyZ1dG1fY2FtcGFpZ249YWZ0cyZvZmZlcl9pZD0xNyZhZmZfaWQ9MzM1NTAmYWZmX3N1Yj1TSEEzMTQzMjExMzkxNQ==";
152
		String url = "aHR0cDovL3d3dy5zbmFwZGVhbC5jb20vcHJvZHVjdC9zb255LXhwZXJpYS10Mi11bHRyYS04Z2IvMjE0Njc5OTEyLz9zdXBjPVNETDI4OTYwOTM5NA==";
148
		byte[] decoded = Base64.decode(url);
153
		byte[] decoded = Base64.decode(url);
149
		System.out.println(new String(decoded));
154
		System.out.println(new String(decoded));
150
		s.setUrl(url);
155
		s.setUrl(url);
151
		System.out.println(s.getColorMessage().getMessage());
156
		System.out.println(s.getColorMessage().getMessage());
-
 
157
		//memcachedClient.set("java", "bawaaaa");
-
 
158
		//System.out.println(memcachedClient.get("hi"));
152
	}
159
	}
153
 
160
 
154
}
161
}
155
162