Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

C# and htmlagility


BeNjO
 Share

Recommended Posts

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.


You work as Graveyard Gardener

Work time |


|

|



```
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
Link to comment
Share on other sites

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.


You work as Graveyard Gardener

Work time |


|

########this line here

|



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)

```
Link to comment
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
 Share

×
×
  • Create New...