Üyelik Tarihi: 17.04.2003
Yer: Istanbul
Yaş: 24
Mesaj: 267
|
Re: Google - PageRank Bulucu
Alıntı:
|
blurise tarafından gönderilen mesaj:
Kaynak kodunu acmayi dusunuyor musun?
|
Buyur...
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
namespace pagerank
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Page Ranking : System.Windows.Forms.form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox adres;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label sonuc;
private System.Windows.Forms.Button bul;
private System.Windows.Forms.Label label3;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private const string strDesen = @"([0-9]{1,2}\sout\sof\s[0-9]{2})";
private const string strSiteAdresi = "http://rankwhere.com/Google-page-rank.PHP?url=";
public Page Ranking()
{
//
// Required for Windows form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Page Ranking));
this.label1 = new System.Windows.Forms.Label();
this.adres = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.sonuc = new System.Windows.Forms.Label();
this.bul = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.font = new System.Drawing.font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(162)));
this.label1.Location = new System.Drawing.Point(104, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 16);
this.label1.TabIndex = 0;
this.label1.Text = "site Adresi";
//
// adres
//
this.adres.font = new System.Drawing.font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.adres.Location = new System.Drawing.Point(32, 24);
this.adres.Name = "adres";
this.adres.Size = new System.Drawing.Size(224, 21);
this.adres.TabIndex = 1;
this.adres.Text = "";
this.adres.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label2
//
this.label2.font = new System.Drawing.font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(162)));
this.label2.Location = new System.Drawing.Point(96, 104);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 2;
this.label2.Text = "Sonuç :";
this.label2.Visible = false;
//
// sonuc
//
this.sonuc.font = new System.Drawing.font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(162)));
this.sonuc.ForeColor = System.Drawing.Color.Brown;
this.sonuc.Location = new System.Drawing.Point(152, 104);
this.sonuc.Name = "sonuc";
this.sonuc.Size = new System.Drawing.Size(56, 16);
this.sonuc.TabIndex = 3;
this.sonuc.Visible = false;
//
// bul
//
this.bul.font = new System.Drawing.font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(162)));
this.bul.Location = new System.Drawing.Point(96, 56);
this.bul.Name = "bul";
this.bul.Size = new System.Drawing.Size(96, 23);
this.bul.TabIndex = 4;
this.bul.Text = "Bul Bakalım";
this.bul.Click += new System.EventHandler(this.bul_Click);
//
// label3
//
this.label3.font = new System.Drawing.font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(162)));
this.label3.Location = new System.Drawing.Point(48, 144);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(192, 16);
this.label3.TabIndex = 5;
this.label3.Text = "Copyright 2004 (c) Semih Turna";
//
// Page Ranking
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 166);
this.Controls.Add(this.label3);
this.Controls.Add(this.bul);
this.Controls.Add(this.sonuc);
this.Controls.Add(this.label2);
this.Controls.Add(this.adres);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Page Ranking";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Google - pagerank";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Page Ranking());
}
private string IcerikAl(string Ek)
{
WebResponse objRes = null;
try
{
WebRequest objReq = WebRequest.Create(strSiteAdresi+Ek);
objRes = objReq.GetResponse();
}
catch(WebException)
{
MessageBox.Show("Bağlantı Kurulamadı!");
return null;
}
Stream objStr = objRes.GetResponseStream();
StreamReader objRead = new StreamReader(objStr);
return objRead.ReadToEnd().ToString();
}
private string pagerank(string Gelen)
{
MatchCollection MC = Regex.Matches(Gelen,strDesen);
string strRank = null;
foreach (Match xMatches in MC)
{
strRank = xMatches.Groups[1].ToString();
}
return strRank.Replace(" out of ","/");
}
private void bul_Click(object sender, System.EventArgs e)
{
string strAdres = adres.Text;
if (strAdres == string.Empty)
{
MessageBox.Show(this,"site Adresini Giriniz!","Hata",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
bul.Text = "Bekleyin..."; bul.Enabled = false;
if (strAdres.IndexOf("http://") == 1)
{
strAdres = strAdres.Replace("http://","");
}
else
{
string Icerik = IcerikAl(strAdres);
if (Icerik != null)
{
label2.Visible = true; sonuc.Visible = true;
sonuc.Text = pagerank(Icerik);
bul.Text = "Bul Bakalım"; bul.Enabled = true; adres.Text = "";
}
}
}
}
}
}
Mesaj PsyChaos tarafından 20.10.2004 (17:20) yeniden düzenlendi..
|