Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 13:14

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Extracting data for browser bot

Discussion on Extracting data for browser bot within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2009
Posts: 1,656
Received Thanks: 703
Extracting data for browser bot

Hey everyone I have some problems extracting data for my browser bot (for Grepolis).
I wanted to extract information about the army training queue but this is saved in the html file like this:
Code:
<script type="text/html" id="orders_tmpl">
/*<![CDATA[*/
<h4>
	<% if(barracks) { %>
		In training	<% } else { %>
		Construction queue	<% } %>
	(<span id="current_building_order_queue_count">0</span>/7)
</h4>
<% for(var i in orders) { 
	var order = orders[i]; %>
		<div id="unit_order_<%=i%>" class="unit_order_task">
			<div style="position: relative;">		
				<div class="unit_order_task_time">
				<%=readableSeconds(order.to_be_completed_at-order.created_at)%>
				</div>
				<img src="<%=Game.img()%>/game/units/<%=order.unit_id%>_50x50.png" class="unit_order_task_unit"/>
				<div class="unit_order_task_value bold"><%=order.units_left%></div>
				<% if(i == orders.length-1) { %>
					<a href="<%=url(null, 'cancel')%>" class="unit_order_cancel cancel"></a>
				<% } %>
			</div>
		</div>
<% } %>

<% if(orders.length > 0) { %>
	<div id="unit_order_task_right"></div>
<% } else { %>
	<% if(barracks) { %>
		No units in training	<% } else { %>
		No orders in the construction queue	<% } %>
<% } %>
/*]]>*/
</script>
Which means that the html is only generated when the page is loaded in your browser.
Is there any way I can extract this data?

~Uthar
Utharnl is offline  
Old 11/13/2010, 22:53   #2
 
elite*gold: 0
Join Date: Jul 2010
Posts: 388
Received Thanks: 196
It is not "generated". The browser requests it doing a HTTP GET request and then receives it from the server.

Hypertext Transfer Protocol - Wikipedia, the free encyclopedia
SmackJew is offline  
Old 11/13/2010, 23:50   #3
 
elite*gold: 0
Join Date: Aug 2009
Posts: 1,656
Received Thanks: 703
Thanks for the response SmackJew, but I do know what http requests are .
The html source code I posted above is a part of the server response I received after a HTTP GET request.

Unfortunately they are using a javascript templating technique. (This link gives some information about it: )
The problem is that the browser generates this locally so that I can't see the information yet when I get the server response.
Now I know that there are here some more developers here, so I was wondering if someone has a solution for this?

~Uthar
Utharnl is offline  
Old 11/15/2010, 12:59   #4
 
elite*gold: 0
Join Date: Jan 2008
Posts: 113
Received Thanks: 31
Quick Answer:
2 Ways

1 - use webbrowser control
2 - Figure out what the javascript does and than do the same things in your code.

Good luck
hallamasch is offline  
Thanks
1 User
Old 11/15/2010, 20:54   #5
 
elite*gold: 0
Join Date: Aug 2009
Posts: 1,656
Received Thanks: 703
Thanks hallamasch I have some ideas now to get it working with the webbrowser control, will give it a try when I have time.

But I would also like to know how to get it working with javascript, could always become useful for future projects.
The data that I need from the javascript part is saved in the array "orders", do you know a way to read that?

~Uthar
Utharnl is offline  
Old 11/16/2010, 13:26   #6
 
elite*gold: 0
Join Date: Jan 2008
Posts: 113
Received Thanks: 31
Again a Quick answer.

Find the javascript code that generates the orders array.

Since Javascript is client side, the server needs to send the data for the orders array.
Which you can intercept and than build the same functionality that the javascript is doing to that data.
hallamasch is offline  
Old 11/16/2010, 21:03   #7
 
elite*gold: 0
Join Date: Aug 2009
Posts: 1,656
Received Thanks: 703
Found the related javascript code after some time and they are requesting the data with a Ajax.get(...) request from the server.
But haven't been able to capture the corresponding server response yet. I used FireBug for this but will try it later with WireShark, maybe that gives a better result.

//edit
Got the correct server request
The javascript code sends an XMLHttpRequest to the server and by adding
Quote:
X-Requested-With: XMLHttpRequest
to my get request it works just fine.
Thanks for pointing me in the right direction.

~Uthar
Utharnl is offline  
Old 11/17/2010, 04:40   #8
 
elite*gold: 0
Join Date: Jan 2008
Posts: 113
Received Thanks: 31
No Problem, your welcome =)
hallamasch is offline  
Reply


Similar Threads Similar Threads
Problem while iam extracting Zczs
07/26/2010 - SRO Private Server - 6 Replies
i got these problem while i am extracting the game part1 http://img401.imageshack.us/img401/5306/96018379. png please help :confused::confused::
Extracting sounds?
01/03/2010 - Grand Chase - 3 Replies
is there a way to extract sounds from the kom files? or is that against the rules ?
[Help] Extracting .wdf files
09/02/2009 - CO2 Weapon, Armor, Effects & Interface edits - 3 Replies
hello all!! maybe it's not here i need to ask it but... i need a .wdf extractor to make my edits in the login screen of the client... someone can help me ... i will be gratefull
Extracting with WinRar
03/15/2008 - Conquer Online 2 - 8 Replies
Hi guys I wanted to download a Rar file such as archerbuddy1.0... Windows is not letting me so i was told to download Winrar.. I did that.... and people told me to click the Extract button from the pag that page that pops up... I don't understand what to do after you download the file with WinRar, and how



All times are GMT +1. The time now is 13:15.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.