initial commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package de.tilman.AHTreeReader;
|
||||
|
||||
public class AHTreeReader {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package de.tilman.AHTreeReader;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import de.tilman.AHTreeReader.Tree.Node;
|
||||
|
||||
public class PlainApp {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Aloha, funky time");
|
||||
String cookie = "PHPSESSID=5nccupenl4b7tps9048bge76h3";
|
||||
|
||||
Tree<String, String> tr = new Tree<String, String>();
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost("https://media-assistant.animalhealth.bayer.com/assets/php/ajax_loadCategoryTree.php");
|
||||
|
||||
HttpHost target = new HttpHost("media-assistant.animalhealth.bayer.com", 443, "https");
|
||||
HttpHost proxy = new HttpHost("10.185.190.100", 8080, "http");
|
||||
|
||||
// RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
|
||||
// httpPost.setConfig(config);
|
||||
httpPost.setHeader("Cookie", cookie);
|
||||
|
||||
HttpEntity entity = MultipartEntityBuilder.create().addTextBody("parent", "14344").build();
|
||||
httpPost.setEntity(entity);
|
||||
|
||||
CloseableHttpResponse response = httpClient.execute(target, httpPost);
|
||||
|
||||
try {
|
||||
System.out.println(response.getStatusLine());
|
||||
String str = EntityUtils.toString(response.getEntity());
|
||||
|
||||
int startIndex = str.indexOf("</ul>");
|
||||
|
||||
String mainCategories = str.substring(str.indexOf("<ul>", startIndex)+5, str.indexOf("</ul>", startIndex + 5));
|
||||
|
||||
while (mainCategories.length() > 6) {
|
||||
mainCategories = mainCategories.substring(mainCategories.indexOf("catId=") + 7);
|
||||
String key = mainCategories.substring(0, mainCategories.indexOf('"'));
|
||||
mainCategories = mainCategories.substring(mainCategories.indexOf(":void(0)'>") + 10);
|
||||
String value = mainCategories.substring(0, mainCategories.indexOf('<'));
|
||||
mainCategories = mainCategories.substring(mainCategories.indexOf('\n') + 1);
|
||||
mainCategories = mainCategories.substring(mainCategories.indexOf('\n') + 1);
|
||||
|
||||
System.out.println(key + ", " + value);
|
||||
tr.root.children.add(new Node<String, String>(key, value));
|
||||
}
|
||||
|
||||
for (Node<String, String> n : tr.root.children) {
|
||||
httpPost = new HttpPost("https://media-assistant.animalhealth.bayer.com/assets/php/ajax_getCategoryFolderSubnavi.php");
|
||||
// httpPost.setConfig(config);
|
||||
httpPost.setHeader("Cookie", cookie);
|
||||
|
||||
entity = MultipartEntityBuilder.create().addTextBody("parent", n.key).build();
|
||||
httpPost.setEntity(entity);
|
||||
|
||||
response = httpClient.execute(target, httpPost);
|
||||
|
||||
System.out.println("\n\n ~~~~~~~~~~~~~");
|
||||
System.out.println(response.getStatusLine());
|
||||
str = EntityUtils.toString(response.getEntity());
|
||||
|
||||
if (str.indexOf("<ul>") >= 0) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ArrayList<NameValuePair> postParameters;
|
||||
//
|
||||
// postParameters = new ArrayList<NameValuePair>();
|
||||
// postParameters.add(new BasicNameValuePair("param1", "param1_value"));
|
||||
// postParameters.add(new BasicNameValuePair("param2", "param2_value"));
|
||||
//
|
||||
// httpPost.setEntity(new UrlEncodedFormEntity(postParameters));
|
||||
//
|
||||
// HttpResponse response = httpclient.execute(httpPost);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package de.tilman.AHTreeReader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Tree<K,V> {
|
||||
public Node<K,V> root;
|
||||
|
||||
public Tree() {
|
||||
root = new Node<K,V>();
|
||||
root.children = new ArrayList<Node<K,V>>();
|
||||
}
|
||||
|
||||
public static class Node<K,V> {
|
||||
|
||||
public Node() { }
|
||||
|
||||
public Node(K key, V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public K key;
|
||||
public V value;
|
||||
public Node<K,V> parent;
|
||||
public List<Node<K,V>> children = new ArrayList<Node<K,V>>();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user