Can sıkıntısına bir ara test amaçlı bir kaç httpparser kütüphanelerini kurcalamışlığım olmuştu. Kurcalarken kendi websitem ile ilgili arama motorları indexleme,alexa global ve yerel sıralama gibi değerleri için birşey yazmaya karar vermiştim. Genel olarak aslında bitmişti çünkü işleyiş olarak bir her segmenti kodun aynı olacaktır. Daha sonra kendi sunucumda websiteme bir subdomain açıp, uygulamayı orada teste açağım ve açık kaynaklı olacağı için bütün kod sirkülasyonunu ve araçları bu başlık altında paylaşacağım. Kullanmak isteyen arkadaşlar kullanabilir.
Uygulama olduğu gibi java tabanlıdır. Hızlı olması için web tabanlı arayüzde JSP kullandım. Uygulama sunucusu Apache Tomcat'tir. Kullandığım HttpParser kütüphanesi ise açık kaynaklı bir proje olan HtmlUnit'tir.
İlk test ettiğim Google indexleme bilgisi onu paylaşayım.
index.jsp sayfam ve içeriğinde Google indexleme yapan kod.
PHP- Kodu:
[/LEFT][/CODE]
Sorgu yapılan domain ve verilerini tutmak için bit txt dosyası kullandım. count.txt
PHP- Kodu:
[/LEFT][/CODE]
Uygulama olduğu gibi java tabanlıdır. Hızlı olması için web tabanlı arayüzde JSP kullandım. Uygulama sunucusu Apache Tomcat'tir. Kullandığım HttpParser kütüphanesi ise açık kaynaklı bir proje olan HtmlUnit'tir.
İlk test ettiğim Google indexleme bilgisi onu paylaşayım.
index.jsp sayfam ve içeriğinde Google indexleme yapan kod.
PHP- Kodu:
Kod:
[LEFT][CODE][COLOR=#000000] [COLOR=#0000BB] [/COLOR][COLOR=#007700]<%--
[/COLOR][COLOR=#0000BB]Document [/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000BB]index
Created on [/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000BB]Jul 31[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]2012[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]9[/COLOR][COLOR=#007700]:[/COLOR][COLOR=#0000BB]23[/COLOR][COLOR=#007700]:[/COLOR][COLOR=#0000BB]12 PM
Author [/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000BB]turgay[/COLOR]
[COLOR=#007700]--%>
<%@ [/COLOR][COLOR=#0000BB]page import[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"ThirdPartyApp.Count"[/COLOR][COLOR=#007700]%>
<%@ [/COLOR][COLOR=#0000BB]page import[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"ThirdPartyApp.PageRank"[/COLOR][COLOR=#007700]%>
<%@ [/COLOR][COLOR=#0000BB]page import[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"com.gargoylesoftware.htmlunit.html.HtmlDivision"[/COLOR][COLOR=#007700]%>
<%@ [/COLOR][COLOR=#0000BB]page import[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"com.gargoylesoftware.htmlunit.BrowserVersion"[/COLOR][COLOR=#007700]%>
<%@ [/COLOR][COLOR=#0000BB]page import[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"com.gargoylesoftware.htmlunit.html.HtmlPage"[/COLOR][COLOR=#007700]%>
<%@ [/COLOR][COLOR=#0000BB]page import[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"com.gargoylesoftware.htmlunit.WebClient"[/COLOR][COLOR=#007700]%>
<%@ [/COLOR][COLOR=#0000BB]page contentType[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"text/html" [/COLOR][COLOR=#0000BB]pageEncoding[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"UTF-8"[/COLOR][COLOR=#007700]%>
<![/COLOR][COLOR=#0000BB]DOCTYPE html[/COLOR][COLOR=#007700]>
<[/COLOR][COLOR=#0000BB]html[/COLOR][COLOR=#007700]>
<[/COLOR][COLOR=#0000BB]head[/COLOR][COLOR=#007700]>
<[/COLOR][COLOR=#0000BB]meta http[/COLOR][COLOR=#007700]-[/COLOR][COLOR=#0000BB]equiv[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"Content-Type" [/COLOR][COLOR=#0000BB]content[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"text/html; charset=UTF-8"[/COLOR][COLOR=#007700]>
<[/COLOR][COLOR=#0000BB]title[/COLOR][COLOR=#007700]>[/COLOR][COLOR=#0000BB]KP Website SEO Analiz Projesi[/COLOR][COLOR=#007700]</[/COLOR][COLOR=#0000BB]title[/COLOR][COLOR=#007700]>
</[/COLOR][COLOR=#0000BB]head
[/COLOR][COLOR=#007700]<[/COLOR][COLOR=#0000BB]body[/COLOR][COLOR=#007700]>
<[/COLOR][COLOR=#0000BB]h1[/COLOR][COLOR=#007700]>[/COLOR][COLOR=#0000BB]KP Website SEO Analiz Projesi Alfa Test Sürümü[/COLOR][COLOR=#007700]</[/COLOR][COLOR=#0000BB]h1[/COLOR][COLOR=#007700]>
<[/COLOR][COLOR=#0000BB]form action[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"index.jsp" [/COLOR][COLOR=#0000BB]method[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"POST"[/COLOR][COLOR=#007700]>
<[/COLOR][COLOR=#0000BB]input type[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"text" [/COLOR][COLOR=#0000BB]name[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"website" [/COLOR][COLOR=#0000BB]value[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"" [/COLOR][COLOR=#007700]/>
<[/COLOR][COLOR=#0000BB]b[/COLOR][COLOR=#007700]>[/COLOR][COLOR=#0000BB]Ornek [/COLOR][COLOR=#007700]: [/COLOR][COLOR=#DD0000]"www.kodlapaylas.com"[/COLOR][COLOR=#007700]</[/COLOR][COLOR=#0000BB]b[/COLOR][COLOR=#007700]>
<[/COLOR][COLOR=#0000BB]input type[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"submit" [/COLOR][COLOR=#0000BB]value[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]"GÖNDER" [/COLOR][COLOR=#007700]/>
</[/COLOR][COLOR=#0000BB]form[/COLOR][COLOR=#007700]>
<%
[/COLOR][COLOR=#0000BB]Count cnt [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]Count[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]int lastRecord [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000BB]boolean istCheck [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]false[/COLOR][COLOR=#007700];
if ([/COLOR][COLOR=#0000BB]cnt[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]ReadLastRecordNoFromFile[/COLOR][COLOR=#007700]() != [/COLOR][COLOR=#0000BB]0 [/COLOR][COLOR=#007700]&& [/COLOR][COLOR=#0000BB]cnt[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]ReadLastRecordNoFromFile[/COLOR][COLOR=#007700]() != [/COLOR][COLOR=#0000BB]null[/COLOR][COLOR=#007700]) {
[/COLOR][COLOR=#0000BB]lastRecord [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]cnt[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]ReadLastRecordNoFromFile[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]istCheck [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]true[/COLOR][COLOR=#007700];
}
try {
if ([/COLOR][COLOR=#0000BB]istCheck[/COLOR][COLOR=#007700]) {
[/COLOR][COLOR=#0000BB]long maxHeapSize [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Runtime[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]getRuntime[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]maxMemory[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<b>JVM Max Heap Size : </b>" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]maxHeapSize [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"<br>"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]long totalHeapSize [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Runtime[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]getRuntime[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]totalMemory[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<b>JVM Total Heap Size : </b>" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]totalHeapSize [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"</br>"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]long freeHeapSize [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Runtime[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]getRuntime[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]freeMemory[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<b>JVM Free Heap Size : </b>" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]freeHeapSize [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"<br>"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]long processors [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]Runtime[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]getRuntime[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]availableProcessors[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<b>Processors : </b>" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]processors [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"</br>"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]String website [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#007700];
if (![/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]equals[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]request[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]getParameter[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"website"[/COLOR][COLOR=#007700])) && [/COLOR][COLOR=#0000BB]request[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]getParameter[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"website"[/COLOR][COLOR=#007700]) != [/COLOR][COLOR=#0000BB]null[/COLOR][COLOR=#007700]) {
[/COLOR][COLOR=#0000BB]website [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]request[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]getParameter[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"website"[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]toString[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]toLowerCase[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]trim[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<b>Website :</b>" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]website [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"<br>"[/COLOR][COLOR=#007700]);
final [/COLOR][COLOR=#0000BB]WebClient webClient [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]WebClient[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]BrowserVersion[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]FIREFOX_3_6[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]HtmlPage pageC [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]webClient[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]getPage[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"http://www.google.com.tr/search?q=site:" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]website[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]HtmlDivision div [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]pageC[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]getHtmlElementById[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"resultStats"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]int googleStartIndex [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]div[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]asText[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]indexOf[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"Yaklaşık"[/COLOR][COLOR=#007700]) + [/COLOR][COLOR=#0000BB]9[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000BB]int googleEndIndex [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]div[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]asText[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]indexOf[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"sonuç"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]String googleIndexCounter [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]div[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]asText[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]substring[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]googleStartIndex[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]googleEndIndex[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<b>Google Index : </b>" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]googleIndexCounter [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"<br>"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]webClient[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]closeAllWindows[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]lastRecord [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]lastRecord [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000BB]java[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]util[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Date d [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]java[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]util[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Date[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]cnt[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]WriteNewRecordToFile[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]lastRecord [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]" , " [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]website [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]" , " [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]googleIndexCounter [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]" , " [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]d[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]toGMTString[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]substring[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]d[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]toGMTString[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]length[/COLOR][COLOR=#007700]()-[/COLOR][COLOR=#0000BB]3[/COLOR][COLOR=#007700]) + [/COLOR][COLOR=#DD0000]":"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<b>PageRank : </b>" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"Test aşamasında.." [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"</br>"[/COLOR][COLOR=#007700]);
} else {
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<b>Website adı giriniz.</b></br>"[/COLOR][COLOR=#007700]);
}
}
} catch ([/COLOR][COLOR=#0000BB]Exception e[/COLOR][COLOR=#007700]) {
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<div style=\"color:red;\"><b>Hata Oluştu</b></div>"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#FF8000]//e.getMessage();
[/COLOR][COLOR=#007700]} [/COLOR][COLOR=#0000BB]finally [/COLOR][COLOR=#007700]{
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<div style=\"color:red;\">Sorgu Sayısı : <b>" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]lastRecord [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"</b></div>"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<h2><b>Son 50 sorgulanan kayıt</b><br></h2>"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<h4><b>Sıra, Domain , Index Sayısı, Sorgu Tarihi</b><br></h4>"[/COLOR][COLOR=#007700]);
for ([/COLOR][COLOR=#0000BB]Object str [/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000BB]cnt[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]ReadLastFiftyRecordFromFile[/COLOR][COLOR=#007700]()) {
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]println[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"<b>" [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]str [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"<br>"[/COLOR][COLOR=#007700]);
}
}
%>
</[/COLOR][COLOR=#0000BB]body[/COLOR][COLOR=#007700]>
</[/COLOR][COLOR=#0000BB]html[/COLOR][COLOR=#007700]> [/COLOR][/COLOR]
Sorgu yapılan domain ve verilerini tutmak için bit txt dosyası kullandım. count.txt
PHP- Kodu:
Kod:
[LEFT][CODE][COLOR=#000000] [COLOR=#FF8000]/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/[/COLOR]
[COLOR=#0000BB]package ThirdPartyApp[/COLOR][COLOR=#007700];
[/COLOR]
[COLOR=#0000BB]import java[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]io[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]BufferedReader[/COLOR][COLOR=#007700];[/COLOR]
[COLOR=#0000BB]import java[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]io[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]BufferedWriter[/COLOR][COLOR=#007700];[/COLOR]
[COLOR=#0000BB]import java[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]io[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]FileReader[/COLOR][COLOR=#007700];[/COLOR]
[COLOR=#0000BB]import java[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]io[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]FileWriter[/COLOR][COLOR=#007700];[/COLOR]
[COLOR=#0000BB]import java[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]io[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]IOException[/COLOR][COLOR=#007700];[/COLOR]
[COLOR=#0000BB]import java[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]util[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]ArrayList[/COLOR][COLOR=#007700];
[/COLOR]
[COLOR=#FF8000]/**
*
* [MENTION=21475]AuthoR[/MENTION] turgay
*/[/COLOR]
[COLOR=#007700]public class [/COLOR][COLOR=#0000BB]Count [/COLOR][COLOR=#007700]{
private static [/COLOR][COLOR=#0000BB]String path [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]"\\WebApplication3\\web\\count.txt"[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#FF8000]//Counstructor
[/COLOR][COLOR=#007700]public [/COLOR][COLOR=#0000BB]Count[/COLOR][COLOR=#007700]() {
}
[/COLOR][COLOR=#FF8000]//Dosyadan okuma
[/COLOR][COLOR=#007700]@[/COLOR][COLOR=#0000BB]SuppressWarnings[/COLOR][COLOR=#007700]({[/COLOR][COLOR=#DD0000]"ConvertToTryWithResources"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]"UseSpecificCatch"[/COLOR][COLOR=#007700]})
public [/COLOR][COLOR=#0000BB]Integer ReadLastRecordNoFromFile[/COLOR][COLOR=#007700]() [/COLOR][COLOR=#0000BB]throws IOException [/COLOR][COLOR=#007700]{
[/COLOR][COLOR=#0000BB]BufferedReader in [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]null[/COLOR][COLOR=#007700];
try {
[/COLOR][COLOR=#0000BB]in [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]BufferedReader[/COLOR][COLOR=#007700](new [/COLOR][COLOR=#0000BB]FileReader[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]path[/COLOR][COLOR=#007700]));
[/COLOR][COLOR=#0000BB]String str [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]String[/COLOR][COLOR=#007700]();
[/COLOR][COLOR=#0000BB]String[/COLOR][COLOR=#007700][] [/COLOR][COLOR=#0000BB]strArray [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]null[/COLOR][COLOR=#007700];
while ([/COLOR][COLOR=#0000BB]in[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]ready[/COLOR][COLOR=#007700]()) {
[/COLOR][COLOR=#0000BB]strArray [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]in[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]readLine[/COLOR][COLOR=#007700]().[/COLOR][COLOR=#0000BB]split[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]","[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]str [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]strArray[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700]];
}
return [/COLOR][COLOR=#0000BB]Integer[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]valueOf[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]str[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]trim[/COLOR][COLOR=#007700]());
} catch ([/COLOR][COLOR=#0000BB]Exception e[/COLOR][COLOR=#007700]) {
[/COLOR][COLOR=#0000BB]e[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]printStackTrace[/COLOR][COLOR=#007700]();
return [/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700];
} [/COLOR][COLOR=#0000BB]finally [/COLOR][COLOR=#007700]{
[/COLOR][COLOR=#0000BB]in[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]close[/COLOR][COLOR=#007700]();
}
}
[/COLOR][COLOR=#FF8000]//Dosyadan son 50 kayıdı okuma
[/COLOR][COLOR=#007700]@[/COLOR][COLOR=#0000BB]SuppressWarnings[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"ConvertToTryWithResources"[/COLOR][COLOR=#007700])
public [/COLOR][COLOR=#0000BB]ArrayList ReadLastFiftyRecordFromFile[/COLOR][COLOR=#007700]() {
[/COLOR][COLOR=#0000BB]ArrayList[/COLOR][COLOR=#007700]<[/COLOR][COLOR=#0000BB]String[/COLOR][COLOR=#007700]> [/COLOR][COLOR=#0000BB]strList [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]ArrayList[/COLOR][COLOR=#007700]<>();
try {
[/COLOR][COLOR=#0000BB]BufferedReader in [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]BufferedReader[/COLOR][COLOR=#007700](new [/COLOR][COLOR=#0000BB]FileReader[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]path[/COLOR][COLOR=#007700]));
[/COLOR][COLOR=#0000BB]int counter [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000BB]String str[/COLOR][COLOR=#007700];
while ([/COLOR][COLOR=#0000BB]in [/COLOR][COLOR=#007700]!= [/COLOR][COLOR=#0000BB]null[/COLOR][COLOR=#007700]) {
[/COLOR][COLOR=#0000BB]str [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]in[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]readLine[/COLOR][COLOR=#007700]();
if ([/COLOR][COLOR=#0000BB]counter [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#0000BB]50 [/COLOR][COLOR=#007700]|| [/COLOR][COLOR=#0000BB]str [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#0000BB]null[/COLOR][COLOR=#007700]) {
break;
}
[/COLOR][COLOR=#0000BB]strList[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]add[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]str[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]substring[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]str[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]length[/COLOR][COLOR=#007700]() - [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]));
[/COLOR][COLOR=#0000BB]counter [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]counter [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700];
}
[/COLOR][COLOR=#0000BB]in[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]close[/COLOR][COLOR=#007700]();
return [/COLOR][COLOR=#0000BB]strList[/COLOR][COLOR=#007700];
} catch ([/COLOR][COLOR=#0000BB]Exception e[/COLOR][COLOR=#007700]) {
[/COLOR][COLOR=#0000BB]strList[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]add[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"Liste şuan boş.."[/COLOR][COLOR=#007700]);
return [/COLOR][COLOR=#0000BB]strList[/COLOR][COLOR=#007700];
}
}
[/COLOR][COLOR=#FF8000]//Dosyaya yazma
[/COLOR][COLOR=#007700]@[/COLOR][COLOR=#0000BB]SuppressWarnings[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"ConvertToTryWithResources"[/COLOR][COLOR=#007700])
public [/COLOR][COLOR=#0000BB]boolean WriteNewRecordToFile[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]String info[/COLOR][COLOR=#007700]) {
try {
[/COLOR][COLOR=#0000BB]BufferedWriter out [/COLOR][COLOR=#007700]= new [/COLOR][COLOR=#0000BB]BufferedWriter[/COLOR][COLOR=#007700](new [/COLOR][COLOR=#0000BB]FileWriter[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]path[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]true[/COLOR][COLOR=#007700]));
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]write[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]info [/COLOR][COLOR=#007700]+ [/COLOR][COLOR=#DD0000]"\n"[/COLOR][COLOR=#007700]);
[/COLOR][COLOR=#0000BB]out[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]close[/COLOR][COLOR=#007700]();
return [/COLOR][COLOR=#0000BB]true[/COLOR][COLOR=#007700];
} catch ([/COLOR][COLOR=#0000BB]Exception e[/COLOR][COLOR=#007700]) {
return [/COLOR][COLOR=#0000BB]false[/COLOR][COLOR=#007700];
}
}
} [/COLOR][/COLOR]