Source code for a simple backlinking app

Discussion in '.NET' started by shedboy, Dec 14, 2010.

  1. shedboy

    shedboy Make Money Online

    Joined:
    Jul 31, 2009
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    I though we could do with some more code examples

    This is basically the source code for a little app I programmed for myself. Its similar to the masses of those backlinkng apps that are out there

    Note

    The url to be submitted is in const string url = "myurl.net"; realistically this would be better to be a text box that accepts a url and stores the reults in a variable

    Sources.txt contains a list of 'backlink sites' in the format at http://whois.domaintools.com/{website}

    I'll try and make some improvements at some time and zip up the project and exe

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.IO;
    using System.Net;
    using System.Text;
    using System.Windows.Forms;
    
    namespace Backlinker
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                const string f = "sources.txt";
                const string url = "myurl.net";
                const string placeholder = "{website}";
                string backurl, submiturl;
    
                List<string> lines = new List<string>();
                using (StreamReader r = new StreamReader(f))
                {
                    string line;
                    while ((line = r.ReadLine()) != null)
                    {
                        lines.Add(line);
                    }
                }
    
                int count = lines.Count();
                int i = 0;
                FileStream MyFile = new FileStream("report.txt", FileMode.OpenOrCreate);
                StreamWriter MyWriter = new StreamWriter(MyFile);
                while (i <= count - 1)
                {
    
                    //get the backlink site from the list
                    backurl = lines[i];
                    //replace the placeholder text with your url
                    submiturl = backurl.Replace(placeholder, url);
                    //catch all exceptions
                    try
                    {
                        WebRequest request = WebRequest.Create(submiturl);
                        // Sends the HttpWebRequest and waits for a response.
                        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            MyWriter.Write(submiturl + " successfully submitted");
                            MyWriter.Write(MyWriter.NewLine);
                        }
                        else
                        {
                            MessageBox.Show(submiturl + " Failed");
                            MyWriter.Write(MyWriter.NewLine);
                        }
                        response.Close();
    
                    }
                    catch (WebException we)
                    {
                        MyWriter.Write("\r\nWebException Raised. The following error occured : {0}", we.Status);
                        MyWriter.Write(MyWriter.NewLine);
                    }
                    catch (Exception ex)
                    {
                        MyWriter.Write("\nThe following Exception was raised : {0}", ex.Message);
                        MyWriter.Write(MyWriter.NewLine);
                    }
    
                    i++;
                }
                MessageBox.Show("Submitted to all Backlink sites");
                MyWriter.Close();
                MyFile.Close();
            }
        }
    }
    
     
  2. billion-dollar-man

    billion-dollar-man Make Money Online

    Joined:
    Nov 8, 2010
    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    0
    Why is it that whois-servers are able to make a backlink to you domain?
     
  3. sammib

    sammib Make Money Online

    Joined:
    Jun 16, 2010
    Messages:
    51
    Likes Received:
    0
    Trophy Points:
    0
    Who.is is always there. It is the sourse to find site owners and info about all websites and availability.
     
  4. adonic

    adonic Make Money Online

    Joined:
    Apr 5, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    thanks for sharing your source code
     
  5. Joshua123

    Joshua123 New Member

    Joined:
    Aug 4, 2011
    Messages:
    71
    Likes Received:
    1
    Trophy Points:
    0
    nice ,) maybe u want to check my thread about setting ******s too
     

Share This Page