locked
Backlink Checker Help RRS feed

  • Question

  • User-369740778 posted

    Hello:

    I am trying to figure out the code  (C#) for retrieving backlinks from a website.  I have seen it called a "Backlink Checker".  I also wondering if a crawler/bot might need to be written for this? Any information that can steer me in the right direction would be greatly appreciated. - Thanks

    Sunday, April 3, 2016 12:23 AM

Answers

  • User61956409 posted

    Hi Drewstar13,

    I am trying to figure out the code  (C#) for retrieving backlinks from a website.  I have seen it called a "Backlink Checker".  

    This article explained about “Backlink Checker in C#”, you could check it.

    http://www.prodigyproductionsllc.com/articles/programming/backlink-checker-in-c/

     The code snippets

    namespace BacklinkCounter
    {
        class Program
        {
            static void Main(string[] args)
            {
                string url = "www.prodigyproductionsllc.com";
                WebClient wc = new WebClient();
                string html = wc.DownloadString(String.Format("http://siteexplorer.search.yahoo.com/search?p={0}&bwm=i&bwmo=&bwmf=s", url));
    
                string linkCount = GetStringInBetween("<span class="btn">Inlinks (", ")</span>", html, false, false)[0];
    
                Console.WriteLine("Link Count: " + linkCount);
    
                Console.ReadLine();
            }
    
            public static string[] GetStringInBetween(string strBegin, string strEnd, string strSource, bool includeBegin, bool includeEnd)
            {
                string[] result = { "", "" };
                int iIndexOfBegin = strSource.IndexOf(strBegin);
    
                if (iIndexOfBegin != -1)
                {
                    // include the Begin string if desired
                    if (includeBegin)
                        iIndexOfBegin -= strBegin.Length;
    
                    strSource = strSource.Substring(iIndexOfBegin + strBegin.Length);
    
                    int iEnd = strSource.IndexOf(strEnd);
    
                    if (iEnd != -1)
                    {
                        // include the End string if desired
                        if (includeEnd) iEnd += strEnd.Length;
    
                        result[0] = strSource.Substring(0, iEnd);
    
                        // advance beyond this segment
                        if (iEnd + strEnd.Length < strSource.Length)
                            result[1] = strSource.Substring(iEnd + strEnd.Length);
                    }
                }
                else
                    // stay where we are
                    result[1] = strSource;
    
                return result;
            }
        }
    }
    

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 5, 2016 6:49 AM