package ThirdPartyApp;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.io.IOException;
/**
*
* @
[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...] turgay
*/
public class Indexes {
static WebClient webClient = null;
public Indexes() {
}
//Bu metod aşağıdaki bütün metodları sırası ile çalıştırıp, dönen değerleri
//StringBuilder nesnesi içine append ediyor ve metod String bir değer geri
//dönüyor bunuda
seo.kodlapaylas.com'da bir sorgulama yaptıgınızda
//sonucların geldiği kısım olarak söylenebilir
public StringBuilder startWebSiteAnalyze(String website) {
StringBuilder sb = null;
try {
sb = new StringBuilder();
cnt.setSeoDomain(website);
sb.append(googleIndex(website));
sb.append(yahooIndex(website));
sb.append(bingIndex(website));
sb.append(yandexIndex(website));
sb.append(alexaValues(website));
sb.append(googleBackLink(website));
sb.append(isDmoz(website));
if (cnt.InsertNewQuery() == true) {
return sb;
} else {
return sb;
}
} catch (Exception e) {
e.printStackTrace();
return sb;
}
}
//Google arama motoru index istatistik değerini getiren metod
private String googleIndex(String website) {
String returningValue = "";
try {
webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setCssEnabled(false);
webClient.setRedirectEnabled(false);
webClient.setJavaScriptEnabled(false);
HtmlPage pageC = webClient.getPage("
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.website);
HtmlDivision div = pageC.getHtmlElementById("resultStats");
int googleStartIndex = div.asText().indexOf("Yaklaşık") + 9;
int googleEndIndex = div.asText().indexOf("sonuç");
String googleIndexCounter = div.asText().substring(googleStartIndex, googleEndIndex);
returningValue = "<b>Google Index : </b>" + googleIndexCounter + "<br>";
webClient.closeAllWindows();
return returningValue;
} catch (Exception e) {
e.printStackTrace();
return returningValue;
}
}
//Google BackLink sayısını getiren metod
private String googleBackLink(String website) {
String returningValue = "";
try {
webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setCssEnabled(false);
webClient.setRedirectEnabled(false);
webClient.setJavaScriptEnabled(false);
HtmlPage pageC = webClient.getPage("https://
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.website);
HtmlDivision div = pageC.getHtmlElementById("resultStats");
String googleBackLinkCounter = "";
if (div.asText().contains("Yaklaşık")) {
int googleStartIndex = div.asText().indexOf("Yaklaşık") + 9;
int googleEndIndex = div.asText().indexOf("sonuç");
googleBackLinkCounter = div.asText().substring(googleStartIndex, googleEndIndex);
returningValue = "<b>Google BackLink : </b>" + googleBackLinkCounter + "<br>";
} else {
returningValue = "<b>Google BackLink : </b>" + "0" + "<br>";
}
webClient.closeAllWindows();
return returningValue;
} catch (Exception e) {
e.printStackTrace();
return returningValue;
}
}
//Yahoo arama motoru istatistiklerini getiren metod
private String yahooIndex(String website) {
String returningValue = "";
try {
webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setCssEnabled(false);
webClient.setRedirectEnabled(false);
webClient.setJavaScriptEnabled(false);
HtmlPage pageC = webClient.getPage("http://search.yahoo.com/search?p=site:" + website);
HtmlDivision div = pageC.getHtmlElementById("cnt-wrap");
String yahooIndexCounter = div.asText().substring(0, div.asText().length() - 7);
returningValue = "<b>Yahoo Index : </b>" + yahooIndexCounter + "<br>";
webClient.closeAllWindows();
return returningValue;
} catch (Exception e) {
e.printStackTrace();
return returningValue;
}
}
//Bing arama motoru istatistiklerini getiren metod
private String bingIndex(String website) {
String returningValue = "";
try {
webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setCssEnabled(false);
webClient.setRedirectEnabled(false);
webClient.setJavaScriptEnabled(false);
HtmlPage pageC = webClient.getPage("
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.website);
HtmlDivision div = pageC.getHtmlElementById("sw_main");
int bingEndIndex = div.asText().indexOf("results");
String bingIndexCounter = div.asText().substring(0, bingEndIndex);
returningValue = "<b>Bing Index : </b>" + bingIndexCounter + "<br>";
webClient.closeAllWindows();
return returningValue;
} catch (Exception e) {
e.printStackTrace();
return returningValue;
}
}
//Yandex arama motoru istatistiklerini getiren metod
private String yandexIndex(String website) {
String returningValue = "";
try {
webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setCssEnabled(false);
webClient.setRedirectEnabled(true);
webClient.setJavaScriptEnabled(true);
HtmlPage pageC = webClient.getPage("http://yandex.com.tr/yandsearch?text=site:" + website);
String div = pageC.asText();
int yandexBeginIndex = div.indexOf("Yandex: ") + 7;
int yandexEndIndex = div.indexOf("sonuç");
String yandexIndexCounter = div.substring(yandexBeginIndex, yandexEndIndex);
returningValue = "<b>Yandex Index : </b>" + yandexIndexCounter + "<br>";
webClient.closeAllWindows();
return returningValue;
} catch (Exception e) {
e.printStackTrace();
return returningValue;
}
}
//Alexa içindeki global, yerel ve backlink değerleri
private String alexaValues(String website) throws IOException {
String returningValue = "";
try {
webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setCssEnabled(false);
webClient.setRedirectEnabled(true);
webClient.setJavaScriptEnabled(true);
HtmlPage pageC = webClient.getPage("
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.website);
HtmlDivision htmlDiv = pageC.getHtmlElementById("search");
String tableHtml = htmlDiv.asText();
String myNecessaryBlock = tableHtml.substring(tableHtml.indexOf("Alexa Traffic"), tableHtml.indexOf("Star"));
int alexaGlobalBeginIndex = myNecessaryBlock.indexOf("Alexa Traffic Rank:") + 19;
int alexaGlobalEndIndex = 0;
if (myNecessaryBlock.contains("No regional data")) {
alexaGlobalEndIndex = myNecessaryBlock.indexOf("No regional data");
} else if (myNecessaryBlock.contains("Traffic Rank in")) {
alexaGlobalEndIndex = myNecessaryBlock.indexOf("Traffic Rank in");
}
String alexaGlobal = myNecessaryBlock.substring(alexaGlobalBeginIndex, alexaGlobalEndIndex);
int alexaLocalBeginIndex = 0;
String alexaLocal = "";
if (tableHtml.contains("Traffic Rank in")) {
alexaLocalBeginIndex = myNecessaryBlock.indexOf("Traffic Rank in ") + 16;
int alexaLocalEndIndex = myNecessaryBlock.indexOf("Sites Linking In:");
alexaLocal = myNecessaryBlock.substring(alexaLocalBeginIndex, alexaLocalEndIndex);
} else if (tableHtml.contains("No regional data")) {
alexaLocal = "No regional data";
}
int alexaBackLinkBeginIndex = tableHtml.indexOf("Sites Linking In:") + 17;
int alexaBackLinkEndIndex = tableHtml.indexOf("Star");
String alexaBackLink = tableHtml.substring(alexaBackLinkBeginIndex, alexaBackLinkEndIndex - 4);
returningValue = "<b>Alexa Global : </b>" + alexaGlobal + "<br>"
+ "<b>Alexa Local : </b>" + alexaLocal + "<br>"
+ "<b>Alexa BackLink : </b>" + alexaBackLink + "<br>";
webClient.closeAllWindows();
return returningValue;
} catch (Exception e) {
e.printStackTrace();
return returningValue;
}
}
//DMoz kaydının olup olmadığı kontrolü
private String isDmoz(String website) {
String returningValue = "";
try {
boolean isDmoz = false;
webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setCssEnabled(false);
webClient.setRedirectEnabled(false);
webClient.setJavaScriptEnabled(false);
HtmlPage pageC = webClient.getPage("
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.website);
HtmlDivision div = pageC.getHtmlElementById("bd-cross");
if (div.asText().contains("Open Directory Categories")) {
returningValue = "var";
isDmoz = true;
} else {
returningValue = "yok";
isDmoz = false;
}
returningValue = "<b>Dmoz Kaydı : </b>" + returningValue + "<br>";
webClient.closeAllWindows();
return returningValue;
} catch (Exception e) {
e.printStackTrace();
return returningValue;
}
}
}