字母数字穷举排列组合域名,位数递增,网络爬虫,网页抓取

        List> res = Generate("abcdefghijklmnopqrstuvwxyz0123456789-");
            Console.WriteLine("Count = " + res.Count);
            for (int i = 0; i < res.Count; i++)
            {
                Console.WriteLine(res[i]);
            }

        public static List> Generate(string word)
        {
           List> result = new List>();

           List dList = new List();
            foreach (char i in word)
            {
                dList.Add(i.ToString());
            }
            result.Add(dList);

            int a = 0;

            do
            {
                result.Add(GetNext(word, result[a]));
                a++;
            } while (a < result.Count);
            
            return result;
        }
        private static List GetNext(string word, List list)
        {
            List dList = new List();

            int count = list.Count;
            for (int i = 0; i < word.Length; i++)
            {
                for (int a = 0; a < count; a++)
                {
                    dList.Add(word[i].ToString() + list[a]);
                }
            }

            return dList;
        }

输出格式:
a,b,c,……

aa,ab,ac,……
ba,bb,bc,……
ca,cb,cc,……

aaa,aab,aac,……aba,abb,abc,……aca,acb,acc,……
baa,bab,bac,……bba,bbb,bbc,……bca,bcb,bcc,……
caa,cab,cac,……cba,cbb,cbc,……cca,ccb,ccc,……

aaaa,aaab,aaac,……aaba,aabb,aabc,……aaca,aacb,aacc,……

网页抓取、网络爬虫效果图:

字母数字穷举排列组合域名,位数递增,网络爬虫,网页抓取_第1张图片

你可能感兴趣的:(C#技术)