1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[FREE] Quick release that I wrote last night - article spinner [FREE]

Discussion in 'Black Hat SEO Tools' started by Wolfpack, Nov 24, 2011.

  1. Wolfpack

    Wolfpack Junior Member

    Joined:
    Jul 13, 2011
    Messages:
    166
    Likes Received:
    346
    Been a while since I posted anything helpful/anything at all. Here's a small little program I wrote last night in C#, it spins articles using the spintax format, and supports multilevel spinning, i.e.

    Code:
    {this|is|{multi|level|spinning}|as|there's|more{than|one}|layer {of|curly}|brackets}
    
    It's not exactly the most extensive program, but it's a quick put-together which I think a lot of people will want. Have fun, and report bugs here :)

    PS: Don't know if it needs a virus check because it's only 7KB and archived, but if anybody wants to do a virus check and post the stats that'd be really helpful, no idea how to do it or what to use, as I've never uploaded a .exe

    Aussi, here's a screenshot of it in action:
    [​IMG]

    On request, here's the source code :)

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Text.RegularExpressions;
    using System.IO;
    
    namespace WindowsFormsApplication36
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                lblError.Visible = false;
            }
    
            private static readonly Random random = new Random();
            private static readonly object syncLock = new object();
    
            private void button1_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Split('{').Length == textBox1.Text.Split('}').Length)
                {
                    string text = textBox1.Text;
                    string carrier;
                    MatchCollection md = Regex.Matches(text, "\\{[\\s\\S]*\\}*");
                    foreach (Match d in md)
                    {
                        string dstr = d.Value;
                        carrier = LongSpinner(dstr);
                        text = textBox2.Text = Regex.Replace(text, Regex.Escape(d.Value), carrier);
                    }
                    lblCharCount.Text = textBox2.Text.Length.ToString();
                    string unique = Uniqueness(textBox1.Text);
                    if (unique != "")
                    {
                        lblUnique.Text = unique + "%";
                    }
                    else
                    {
                        lblUnique.Text = "0.00%";
                    }
                    if (Combinations(textBox1.Text) > 1000000 | Combinations(textBox1.Text) < 0)
                    {
                        lblCombination.Text = "1,000,000+";
                    }
                    else
                    {
                        lblCombination.Text = Combinations(textBox1.Text).ToString();
                    }
                }
                else
                {
                    lblError.Visible = true;
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Split('{').Length == textBox1.Text.Split('}').Length)
                {
                    string text = textBox1.Text;
                    string carrier;
                    MatchCollection md = Regex.Matches(text, "\\{[\\s\\S]*\\}*");
                    Random rnd = new Random();
                    foreach (Match d in md)
                    {
                        string dstr = d.Value;
                        carrier = Spinner(dstr, rnd);
                        text = textBox2.Text = Regex.Replace(text, Regex.Escape(d.Value), carrier);
                    }
                    lblCharCount.Text = textBox2.Text.Length.ToString();
                    string unique = Uniqueness(textBox1.Text);
                    if (unique != "")
                    {
                        lblUnique.Text = unique + "%";
                    }
                    else
                    {
                        lblUnique.Text = "0.00%";
                    }
                    if (Combinations(textBox1.Text) > 1000000)
                    {
                        lblCombination.Text = "1,000,000+";
                    }
                    else
                    {
                        lblCombination.Text = Combinations(textBox1.Text).ToString();
                    }
                }
                else
                {
                    lblError.Visible = true;
                }
            }
    
            private void textBox1_TextChanged(object sender, EventArgs e)
            {
                lblError.Visible = false;
            }
    
            private void button7_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Split('{').Length == textBox1.Text.Split('}').Length)
                {
                    string text = textBox1.Text;
                    string carrier;
                    MatchCollection md = Regex.Matches(text, "\\{[\\s\\S]*\\}*");
                    Random rnd = new Random();
                    foreach (Match d in md)
                    {
                        string dstr = d.Value;
                        carrier = ShortSpinner(dstr);
                        text = textBox2.Text = Regex.Replace(text, Regex.Escape(d.Value), carrier);
                    }
                    lblCharCount.Text = textBox2.Text.Length.ToString();
                    string unique = Uniqueness(textBox1.Text);
                    if (unique != "")
                    {
                        lblUnique.Text = unique + "%";
                    }
                    else
                    {
                        lblUnique.Text = "0.00%";
                    }
                    if (Combinations(textBox1.Text) > 1000000)
                    {
                        lblCombination.Text = "1,000,000+";
                    }
                    else
                    {
                        lblCombination.Text = Combinations(textBox1.Text).ToString();
                    }
                }
            }
    
            private string Spinner(string mstr, Random rdm)
            {
                string returnword;
                string[] arrSplit;
                int cnt = 0;
                while (Regex.IsMatch(mstr, "\\{"))
                {
                    string innerspin = mstr.Split('{')[(mstr.Split('{').Length) - 1];
                    string tospin = Regex.Match(innerspin, "[\\s\\S]*?(?=\\})").Value;
    
                    arrSplit = tospin.Split('|');
                    returnword = arrSplit[rdm.Next(0, arrSplit.Length)];
                    cnt++;
                    Console.WriteLine(cnt);
    
                    mstr = Regex.Replace(mstr, "\\{" + Regex.Escape(tospin) + "\\}", returnword);
                }
                return mstr;
            }
    
            private string LongSpinner(string mstr)
            {
                string returnword;
                string[] arrSplit;
                int cnt = 0;
                while (Regex.IsMatch(mstr, "\\{"))
                {
                    string innerspin = mstr.Split('{')[(mstr.Split('{').Length) - 1];
                    string tospin = Regex.Match(innerspin, "[\\s\\S]*?(?=\\})").Value;
                    int idx = 0;
                    int x = 0;
                    int longcount = 0;
    
                    arrSplit = tospin.Split('|');
                    foreach (string str in arrSplit)
                    {
                        int length = str.Length;
                        if (length > longcount)
                        {
                            longcount = length;
                            idx = x;
                        }
                        x++;
                    }
                    returnword = arrSplit[idx];
    
                    cnt++;
                    Console.WriteLine(cnt);
    
                    mstr = Regex.Replace(mstr, "\\{" + Regex.Escape(tospin) + "\\}", returnword);
                }
                return mstr;
            }
    
            private int Combinations(string text)
            {
                MatchCollection mc = Regex.Matches(text, "\\{[\\s\\S]*?\\}");
    
                int combno = 1;
    
                foreach (Match m in mc)
                {
                    string[] arrMatch = m.Value.Split('|');
                    combno *= arrMatch.Length;
                    if (combno > 1000000)
                    {
                        break;
                    }
                }
                return combno;
            }
    
    
            private string Uniqueness(string text)
            {
                int spincount = 0;
                int allcount = 0;
    
                MatchCollection notspun = Regex.Matches(text, "\\{[\\s\\S]*?\\}");
                foreach (Match m in notspun)
                {
                    spincount += m.Value.Length;
                }
                MatchCollection all = Regex.Matches(text, "[\\S]*");
                foreach (Match m in all)
                {
                    allcount += m.Value.Length;
                }
                int nonspun = allcount - spincount;
    
                MatchCollection mc = Regex.Matches(text, "(?<=\\{)[\\s\\S]*?(?=\\})");
                decimal[] arrDoubles = new decimal[mc.Count];
                int x = 0;
                foreach (Match m in mc)
                {
                    int averagelengthcnt = 0;
                    string[] arrMatch = m.Value.Split('|');
                    foreach (string s in arrMatch)
                    {
                        averagelengthcnt += s.Length;
                    }
                    arrDoubles[x] = Decimal.Divide(averagelengthcnt, arrMatch.Length);
                    x++;
                }
                return text = (Decimal.Divide(arrDoubles.Sum(), (arrDoubles.Sum() + nonspun)) * 100).ToString("#.##");
            }
    
            public static int RandomNumber(int min, int max)
            {
                lock (syncLock)
                {
                    return random.Next(min, max);
                }
            }
    
            private string ShortSpinner(string mstr)
            {
                string returnword;
                string[] arrSplit;
                int cnt = 0;
                while (Regex.IsMatch(mstr, "\\{"))
                {
                    string innerspin = mstr.Split('{')[(mstr.Split('{').Length) - 1];
                    string tospin = Regex.Match(innerspin, "[\\s\\S]*?(?=\\})").Value;
                    int idx = 0;
                    int x = 0;
                    int longcount = 0;
                    int firstcnt = 0;
    
                    arrSplit = tospin.Split('|');
                    foreach (string str in arrSplit)
                    {
                        int length = str.Length;
                        if (length < longcount | (longcount == 0 && firstcnt == 0))
                        {
                            longcount = length;
                            idx = x;
                            firstcnt++;
                        }
                        x++;
                    }
                    returnword = arrSplit[idx];
    
                    cnt++;
                    Console.WriteLine(cnt);
    
                    mstr = Regex.Replace(mstr, "\\{" + Regex.Escape(tospin) + "\\}", returnword);
                }
                return mstr;
            }
    
            private void button5_Click(object sender, EventArgs e)
            {
                dlgSave.Filter = "Text Files|*.txt";
                DialogResult drUsr;
                drUsr = dlgSave.ShowDialog();
                if (drUsr == DialogResult.OK)
                {
                    FileStream fs = new FileStream(dlgSave.FileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
                    StreamWriter sw = new StreamWriter(fs, Encoding.ASCII);
                    sw.Write(textBox1.Text);
                    sw.Flush();
                    sw.Close(); 
                    fs.Close();
                }
            }
    
            private void button6_Click(object sender, EventArgs e)
            {
                textBox2.Text = "";
            }
    
            static System.Timers.Timer Time = new System.Timers.Timer(8000);
            static bool signaler = false;
    
            static void _timer_Elapsed(object sender, ElapsedEventArgs e)
            {
                signaler = true;
                Time.Enabled = false;
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                dlgOpen.Filter = "Text Files|*.txt";
                DialogResult drUsr;
                drUsr = dlgOpen.ShowDialog();
                if (drUsr == DialogResult.OK)
                {
                    StreamReader sr = new StreamReader(dlgOpen.FileName);
                    textBox1.Text = sr.ReadToEnd();
                }
            }
    
            private void button4_Click(object sender, EventArgs e)
            {
                textBox1.Text = "";
            }
        }
    }
    
     

    Attached Files:

    • Thanks Thanks x 9
    Last edited: Nov 24, 2011
  2. gogorilazz

    gogorilazz Newbie

    Joined:
    Nov 23, 2011
    Messages:
    19
    Likes Received:
    1
    awesome, will test the program. Is that a rabbit on your avatar??
     
  3. Wolfpack

    Wolfpack Junior Member

    Joined:
    Jul 13, 2011
    Messages:
    166
    Likes Received:
    346
    Hell yeah.
     
  4. dgthiyagu

    dgthiyagu Regular Member

    Joined:
    Mar 23, 2011
    Messages:
    266
    Likes Received:
    141
    doesn work for me... spinning doesn work,.... running on windows 7 32 bit
     
  5. Wolfpack

    Wolfpack Junior Member

    Joined:
    Jul 13, 2011
    Messages:
    166
    Likes Received:
    346
    Please post what text you were trying to spin, and I'll see what the problem is :)
     
  6. Sui<3

    Sui<3 Registered Member

    Joined:
    Sep 1, 2010
    Messages:
    52
    Likes Received:
    15
    Why don't you post the source code?
     
  7. Wolfpack

    Wolfpack Junior Member

    Joined:
    Jul 13, 2011
    Messages:
    166
    Likes Received:
    346
    Fair play, if that's what people want :) Edited the original post, it's a quickly made program so don't expect anything magical in my code.
     
    • Thanks Thanks x 1
  8. Sui<3

    Sui<3 Registered Member

    Joined:
    Sep 1, 2010
    Messages:
    52
    Likes Received:
    15
    Thanks.
    Btw: I'd catch those nasty DivideByZero-Exceptions when I don't check the divisor.
     
    • Thanks Thanks x 1
  9. christoss1959

    christoss1959 Senior Member

    Joined:
    Nov 25, 2010
    Messages:
    894
    Likes Received:
    1,150
    Home Page:
    I shared a way to spin in the VB.net section of the forum which is much more reliable (you can convert it easily to C using a code converter)
     
  10. Wolfpack

    Wolfpack Junior Member

    Joined:
    Jul 13, 2011
    Messages:
    166
    Likes Received:
    346
    Stupid of me to forget that, haven't had to deal with much math-related coding in forever now, lol. All about iterations when it comes to software lately.

    Please post a link so I can compare? This was a quick post, I know it's not a fantastic program but it works for the most part, it's only the birth of about 2 hour's thought
     
  11. Capixaba Master

    Capixaba Master Registered Member

    Joined:
    Dec 19, 2010
    Messages:
    90
    Likes Received:
    38
    Home Page:
    Dont work to me.
     
    • Thanks Thanks x 1
  12. Wolfpack

    Wolfpack Junior Member

    Joined:
    Jul 13, 2011
    Messages:
    166
    Likes Received:
    346
    Please explain more in depth, what OS, what kind of problem, etc. Thanks :)
     
  13. creditandgolfse

    creditandgolfse Registered Member

    Joined:
    Dec 22, 2009
    Messages:
    84
    Likes Received:
    39
    very nice.. includes source code as well.. I built my own text spinner in excel macros lol much less lines but wasn`t multi level
     
  14. moonlighsunligh

    moonlighsunligh Jr. VIP Jr. VIP Premium Member

    Joined:
    May 1, 2010
    Messages:
    1,623
    Likes Received:
    218
    Actually this is vb.net function that does nested spinning. It is very very short. I have extracted it from the Wolfpacks script and modified the code a bit, so it is now perfect for integrating into a software, that still haven't got built in a nested spinner.

     
    • Thanks Thanks x 4
    Last edited: Jun 12, 2012
  15. moneygrows

    moneygrows Registered Member

    Joined:
    Jan 9, 2012
    Messages:
    60
    Likes Received:
    73
    Location:
    In Your Mind
    works with windows 7 ultimate 32 bit!
     
  16. moonlighsunligh

    moonlighsunligh Jr. VIP Jr. VIP Premium Member

    Joined:
    May 1, 2010
    Messages:
    1,623
    Likes Received:
    218
    You mean in visual studio on windows 7?

    "mstr = Regex.Replace(mstr, "\{" & Regex.Escape(tospin) & "\}", returnword)" should be changed to mstr = Regex.Replace(mstr, "\{" & Regex.Escape(tospin) & "\}", returnword,1) so just the first match would be replaced.

    Otherwise if some phrase under under curly quotes (level 1 spin) appears in the text more than one time, then all appearances of this phrase are going to be replaced with the same word. This is bad. It is much better to replace each of these appearances of the phrase, with a random word defined by spintax.
     
  17. smirker

    smirker Junior Member

    Joined:
    Oct 2, 2010
    Messages:
    103
    Likes Received:
    35
    Location:
    Australia
    One critical flaw here, is that you have this inside the function:

    Code:
    Dim rdm As New Random()
    If you call this function multiple times very quickly, say, inside a loop, the Random() class will instantiate an RNG with the same seed, as the seed is based on the clock. You will hence get the same spin each time (when called very quickly).

    It's better to use a globally instance of Random, or create one and pass it through if you are calling in a loop.

    If anyone is interested, here is Wolfpack's random spin code, reformatted a bit for easy use. All credits go to Wolfpack:

    Code:
            /// <summary>
            /// Returns a random spin of the supplied text.
            /// </summary>
            /// <param name="spintax">The text, spintax formatted.</param>
            /// <param name="rng">An instance of Random.</param>
            public static string RandomSpin(string spintax, Random rng)
            {
                string returnword;
                string[] arrSplit;
                while (Regex.IsMatch(spintax, "\\{"))
                {
                    string innerspin = spintax.Split('{')[(spintax.Split('{').Length) - 1];
                    string tospin = Regex.Match(innerspin, "[\\s\\S]*?(?=\\})").Value;
    
    
                    arrSplit = tospin.Split('|');
                    returnword = arrSplit[rng.Next(0, arrSplit.Length)];
    
    
                    spintax = Regex.Replace(spintax, "\\{" + Regex.Escape(tospin) + "\\}", returnword);
                }
                return spintax;
            }
    
    
            /// <summary>
            /// Returns a random spin of the supplied text.
            /// CAUTION: If using this in a fast loop, use the other overload with a manually created instance of Random().
            /// </summary>
            /// <param name="spintax">The text, spintax formatted.</param>
            public static string RandomSpin(string spintax)
            {
                return RandomSpin(spintax, new Random());
            }
     
    • Thanks Thanks x 3
  18. AzonGeek

    AzonGeek Jr. VIP Jr. VIP Premium Member

    Joined:
    May 6, 2012
    Messages:
    1,174
    Likes Received:
    510
    Good Job mate ! Just add a Virus total for this.

    Thanks
     
  19. Wolfpack

    Wolfpack Junior Member

    Joined:
    Jul 13, 2011
    Messages:
    166
    Likes Received:
    346
    Best post on this thread :) Thank you so much for the sweet little function, and extra props for the XML comments, +rep!