C# and htmlagility

hey guys,

just curious if anyone can help me, im trying to make a automated, 24/7 bot for a online browser game. I have generally everything working 100% that i have in, but i can not for the life of me figure out how to use the following games code, read it in c# / agility pack then use it to automate a process.

To make things easier i am wanting a sub to get a url from a set point then send said url back like i clicked a button. This is an example.

        {
            bf.console_print("Start Autoskill.");

            string profile = dwc_Http.get("http://s" + bft.serverid + ".en.", bf.settings);
            int increment = 0;

            if (bitefight.skill_strengh)
            {
                while (increment < incrementstrengh)
                {
                    string skilllink = get_skill_link(profile, 1);
                    if (skilllink == null)
                    {
                        // Not enougth gold to skill
                        bf.console_print("Not enough gold to skill(s)");
                        bf.mingold += 1000;
                        return;
                    }
                    profile = dwc_Http.get(skilllink, bf.settings);
                    bf.console_print("Strength +1.");
                    increment++;
                }
            }

this is part of the auto skilling process that basically checks what skill to auto train and this is the get_skill_link

private static string get_skill_link(string profilepage, int id)
        {
            HtmlDocument doc = new HtmlDocument();

            if (profilepage != null)
            {
                doc.LoadHtml(profilepage);

                HtmlNodeCollection skilllinknodes = doc.DocumentNode.SelectNodes("//td/div/a[@href]");

                if (skilllinknodes != null)
                {
                    if (skilllinknodes.Count == 5 && skilllinknodes[id - 1].Attributes["href"] != null)
                    {
                        return skilllinknodes[id - 1].Attributes["href"].Value;
                    }
                }
            }

            return null;
        }

now it obviously checks for href then the 1 time token is used and sent by the bot to auto train clicking the generated link after the ref:

this is the line of code on the site:

href="http://s.com/profile/training/3?__token=3562f98977c9f718a1945b77b43ac9b7"

i made this bot like a year ago, and can not now figure out how to make the bot spend all my energy then “work” for # amount of time whilst my energy regenerates.


	![](/img/npc/0_2.jpg)

###  A feeling of familiarity overcomes you at the graveyard. Welcome Doug

	Not enough gold? At the graveyard you can work as a graveyard gardener for 1.200 [img]/img/symbols/res2.gif[/img] + 217 [img]/img/symbols/res2.gif[/img] per 15 minutes. If you're particularly strong, you can earn a coin or two extra.

<form action="http://s..com/city/graveyard/?__token=3562f98977c9f718a1945b77b43ac9b7" method="POST">
	    You work as Graveyard Gardener

        	 Work time |

                <select name="workDuration" size="1" class="input"><option value="1">0:15:00 h</option> 
                    <option value="2">0:30:00 h</option> 
                    <option value="3">0:45:00 h</option> 
                    <option value="4">1:00:00 h</option> 
                    <option value="5">1:15:00 h</option> 
                    <option value="6">1:30:00 h</option> 
                    <option value="7">1:45:00 h</option> 
                    <option value="8">2:00:00 h</option></select> 
			 |

             |

</form>

what i have tried is replacing form with “” then trying to find action then because i guessed i should be finding form action, but reading online resulted in me having to add a line of code to made the nodes visible.

Anyone got any ideas on how to extract the link using using the same method i am using for the auto skiller? really at a loss here…

Doug

Edit: i should also add, i am kinf of new to c#, i made the bot in like 2011/2012 then it was sitting on a memory pen. I have started to work on the bot, added checks new features etc but can not figure out how to use said form action

forgot to add, willing to pay a small donation, £10-15 when i get paid since its just one sub. further jobs might become open to the person who helps.

looks like im out of look then 😞

Can a mod please move this to recruitment area? if this is allowed there.

Moved the topic at the request of the original poster.

bit of an update, i have managed to extract the full url, i just need help sending the url back so it works, all current attempts have failed me.

I think the fastest way to get a answer would be to post the source, say what your trying to do and how to reproduce it so we could check it out properly. Hard to understand with the info given.

i have posted what the current bot uses to extract the url, not really sure what else to post apart from full source.

what i am trying to do;

my current bot logs me into a browser game, uses all my energy, uses my earned gold to increase my skills etc using a href links, what i now need to do is figure out a way to send a button press to the server. The link it self can not be sent to start work. To start work it uses this line of code:


## [img]/img/symbols/race1small.gif[/img]Graveyard

	![](/img/npc/0_2.jpg)

###  A feeling of familiarity overcomes you at the graveyard. Welcome ####

	Not enough gold? At the graveyard you can work as a graveyard gardener for 1.550 [img]/img/symbols/res2.gif[/img] + 302 [img]/img/symbols/res2.gif[/img] per 15 minutes. If you're particularly strong, you can earn a coin or two extra.

<form action="http://s1.b.gameforge.com/city/graveyard/?__token=9e59c88621ccd9768d" method="POST">
	    You work as Graveyard Gardener

        	 Work time |

                <select name="workDuration" size="1" class="input"><option value="1">0:15:00 h</option> 
                    <option value="2">0:30:00 h</option> 
                    <option value="3">0:45:00 h</option> 
                    <option value="4">1:00:00 h</option> 
                    <option value="5">1:15:00 h</option> 
                    <option value="6">1:30:00 h</option> 
                    <option value="7">1:45:00 h</option> 
                    <option value="8">2:00:00 h</option></select> 
			 |

			########this line here	

             |

</form>

i just need to make a button press packet back to the server, i'm using HTML Agility but all my other work has gone off a href's and not sure how to do what i need to do (simulate a button press to start work)

still looking

managed to do this adding the webbrowser control, but it then kicks my program out, im guessing cookies? Need help still

I had trouble with cookies when I was using the webbrowser control and eventually ended up using Awesomium which is a free for non commercial use webbrowser control. So you could try that.

Log in to reply