Jump to content
Free trial for all, just make a forum account => download loader => follow faq => play ×
Stripe will no longer be supported ×
14.8 Patch Update ×
ouijaaa

Spell Data Scraper

Recommended Posts

Hello there, i'm presenting this scraper that gets updated data from lol.fandom.com/wiki/(championName)

It's working with HtmlAgilityPack so make sure to add that to your project if you want to use this.

For now it grabs the Spell Slot named as for ex. [Q]
and gets the Cost/Cooldown/Area of Effect/Range for it
if that spell for ex. doesn't have any Range then it won't display any Range for it.

Here's the Class code: 
 

public class SpellGrab
    {
        private string champData;
        private string basedOnChannelRange;

        public void DownloadDataForChamp(string championName)
        {
            Console.WriteLine("Champion: "+championName);

            string link = "https://lol.fandom.com/wiki/" + championName;
            champData = new System.Net.WebClient().DownloadString(link);

            var doc = new HtmlDocument();
            doc.LoadHtml(champData);


            var div = doc.DocumentNode.SelectNodes("//table//tbody//tr//td");

            foreach (var childNode in doc.DocumentNode.SelectNodes("//abbr") ?? Enumerable.Empty<HtmlNode>())
            {
                HtmlNode hNewMode = doc.CreateTextNode(childNode.ChildNodes[0].InnerHtml);

                childNode.ChildNodes[0].InnerHtml = childNode.ChildNodes[0].InnerText;
              
                if (childNode.OuterHtml.Contains("based on channel") && !childNode.InnerHtml.Contains("%"))
                {
                    basedOnChannelRange = " "+childNode.ChildNodes[0].InnerHtml;
                }
            }

            if (div != null)
            {
                string currentSpell = "";

                List<string> spellList = new List<string>();

                foreach (var item in div)
                {

                    if (item.ChildNodes.Count > 0)
                    {

                        var text = item.ChildNodes[0].InnerText;
                        if (text.StartsWith("[Passive]"))
                        {
                            currentSpell = "[Passive]";
                        }
                        else if (text.StartsWith("[Q]"))
                        {
                            currentSpell = "[Q]";
                        }
                        else if (text.StartsWith("[W]"))
                        {
                            currentSpell = "[W]";
                        }
                        else if (text.StartsWith("[E]"))
                        {
                            currentSpell = "[E]";
                        }
                        else if (text.StartsWith("[R]"))
                        {
                            currentSpell = "[R]";
                        }
                    } //qwer etc


                    if (item.ChildNodes.Count > 1)
                    {
                        //Console.WriteLine(currentSpell);
                        var text = item.ChildNodes[0].InnerText;
                        //Console.WriteLine(currentSpell);
                        if (text.StartsWith("Cost"))
                        {
                            spellList.Add(currentSpell + text + item.ChildNodes[0].NextSibling.InnerText);
                        }
                        if (text.StartsWith("Cooldown"))
                        {
                            spellList.Add(currentSpell + text + item.ChildNodes[0].NextSibling.InnerText);
                        }

                        if (text.StartsWith("Area of Effect"))
                        {
                            spellList.Add(currentSpell + text + item.ChildNodes[0].NextSibling.InnerText);
                        }

                        if (!item.InnerHtml.Contains("based on channel"))
                        {
                            if (text.StartsWith("Range"))
                            {
                                spellList.Add(currentSpell + text + item.ChildNodes[0].NextSibling.InnerText);
                            }
                        }
                        else if (item.InnerHtml.Contains("based on channel") && !text.StartsWith("First Cast"))
                        {
                            spellList.Add(currentSpell + text + basedOnChannelRange);
                        }
                    }
                }


                spellList = spellList.Distinct().ToList();

                foreach (var text in spellList)
                {
                    Console.WriteLine(text);
                }
            }



            Console.ReadLine();
            //Console.WriteLine(range);
        }
    }


How to use it?
 

SpellGrab grabData = new SpellGrab();
grabData.DownloadDataForChamp("Varus");


It will print out every data into the Console like this:
 

Champion: Varus
[Q]Cost: 65 / 70 / 75 / 80 / 85 Mana
[Q]Cooldown: 16 / 15 / 14 / 13 / 12s
[Q]Range: 925 - 1625
[W]Cost: No Cost
[W]Cooldown: 40s
[E]Cost: 80 Mana
[E]Cooldown: 18 / 16 / 14 / 12 / 10s
[E]Range: 925
[E]Area of Effect: 300
[R]Cost: 100 Mana
[R]Cooldown: 100 / 80 / 60s
[R]Range: 1200


Notice: Range (and others) may also contain stuff like 900 / 1100 / 1300 (based on R level for example) depending on your champion.

What i want to add next:
Filter everything out into a Class made specifically for this and then you should be able to simply call SpellQ.Cooldown

If you have any improvements / suggestions then please tell me.

Edited by ouijaaa
gib suggestions yes

Share this post


Link to post
Share on other sites

I've scraped all champions, everything is in the .json below
there are small mistakes within the .json but i'm fixing them manually as it affects only few champions

i've added a chargeable bool with min/max spellranges for spells like Xerath Q

it's still early for this .json but it's very usable

What i've changed:
if the spell range is a global range it's now set to 30.000

Something to note:
spells for Aphelios are kind of broken (W & E)
some ranges are displayed weirdly like Warwick's R which currently is "250%currentMovementSpeed"
some ranges dont even exist, instead they are written as "areofeffect", that's how the website writes it as.

Here's the .json code
 

    public class SpellData
    {
        public string champName { get; set; }
        public List<SpellDetails> spelldetails { get; set; }
    }

    public class SpellDetails
    {
        public string slot { get; set; }
        public string cost { get; set; }
        public string cooldown { get; set; }
        public string range { get; set; }
        public string minRange { get; set; }
        public string maxRange { get; set; }
        public bool chargeable { get; set; }
        public string areaofeffect { get; set; }
    }


Edit: i fixed all ranges, if a range is not present then use either areaofeffect or the SDK range as it can be a simple Active buff without range
for Nidalee/Kled etc where they can transform i used their max range transformation
so Nidalee ranges are her Human ranges, Kled Mini version etc...

 

spellDB.json

Edited by ouijaaa

Share this post


Link to post
Share on other sites

Feels like Record would be better for this case instead of class but great job. :classic_biggrin:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...