The webpage has the following source (only copied the important part):
<h1>Relatórios</h1>
<div id="textmenu">
<a href="berichte.php" class="selected ">Tudo</a>
| <a href="berichte.php?t=2">Comércio</a>
| <a href="berichte.php?t=1">Reforços</a>
| <a href="berichte.php?t=3">Ataques</a>
| <a href="berichte.php?t=4">Outros</a>
</div>
<form method="post" action="berichte.php" name="msg">
<table cellpadding="1" cellspacing="1" id="overview"
class="row_table_data">
<thead>
<tr>
<th colspan="2">Assunto:</th>
<th class="sent">
enviada</th>
</tr>
</thead><tfoot>
<tr> <th> </th>
<th class=buttons><input name=del value=apagar alt=apagar type=image id=btn_delete class=dynamic_img
src=img/x.gif /></th>
<th class=navi>«<a href="berichte.php?s=10&o=0">»</a></th>
</tr>
</tfoot>
<tbody>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n1"
value="15737030" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15737030">Rio Grande Do Leste ataca lcsanchez da aldeia</a> </div>
</td>
<td class="dat">hoje 21:33</td>
</tr>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n2"
value="15736877" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15736877">Rio Grande Do Leste ataca Thabiti da aldeia</a> </div>
</td>
<td class="dat">hoje 21:32</td>
</tr>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n3"
value="15736759" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15736759">Rio Grande Do Leste ataca Dionisio</a> </div>
</td>
<td class="dat">hoje 21:31</td>
</tr>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n4"
value="15736513" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15736513">Rio Grande Do Leste ataca Aldeia de troakris</a> (nova)</div>
</td>
<td class="dat">hoje 21:30</td>
</tr>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n5"
value="15736275" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15736275">Rio Grande Do Leste ataca Thabiti da aldeia</a> </div>
</td>
<td class="dat">hoje 21:28</td>
</tr>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n6"
value="15736220" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15736220">Rio Grande Do Leste ataca Aldeia de troakris</a> (nova)</div>
</td>
<td class="dat">hoje 21:28</td>
</tr>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n7"
value="15734824" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15734824">Rio Grande Do Leste ataca Austrália</a> </div>
</td>
<td class="dat">hoje 21:18</td>
</tr>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n8"
value="15734440" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15734440">Rio Grande Do Leste ataca andrômeda</a> (nova)</div>
</td>
<td class="dat">hoje 21:15</td>
</tr>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n9"
value="15730612" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15730612">Rio Grande Do Leste ataca wLG02 KING OF POP</a> (nova)</div>
</td>
<td class="dat">hoje 20:49</td>
</tr>
<tr>
<td class="sel"><input class="check" type="checkbox" name="n10"
value="15730304" /></td>
<td class="sub"><img src="img/x.gif"
class="iReport iReport1"
alt="Ganhou como atacante sem perdas"
title="Ganhou como atacante sem perdas" />
<div><a href="berichte.php?id=15730304">Rio Grande Do Leste ataca wLG02 KING OF POP</a> (nova)</div>
</td>
<td class="dat">hoje 20:47</td>
</tr>
</tbody>
</table>
</form>
</div>
I want to read from the source and assign to a variable the values like:
relatorio[0] = berichte.php?id=15730304;
relatorio[1] = berichte.php?id=15730612;
...
relatorio[9] = berichte.php?id=15737030;
How to do that? thanks
using XPath or just a regex, I will update with some code in a moment.
this is regex version, not depending in which element your href is.
UPDATE
You can use xhttprequest object to retrieve your page, here is sample
I haven’t tried but theoretically this should do the work.
Details about Regex:
This is Regular expressions used for matching in a string. It’s a small “language” where you describe the pattern and Regular Expression engine will try to match a text using that pattern. It can be used then in many programming languages (C/C++, PHP, Perl, Javascript) or text editing tools.
In this simple regex I said
Find anything that matches
href=berichte\.php\?id=(slashes are to escape.and?, because they are control symbols for regex) literally/as plain text/ then following [\d] (this is character class in square brackets[]and inside\dit says match a digit). Finally a+means one or many times and applies to last group, which is digit. the whole thing is enclosed in()which is capturing group. But you can also avoid it, by just replacingmatch[1]tomatch[0]. 0 element will always contain the whole match and the others are pointing to capturing groups if they are exist. You can have many capturing groups. It could have been useful if you wanted to capture only theidvalue, then you could just write like thatthis will fill up match1 with
idvalues.Sorry can’t explain you all regex here, but there are plenty of resources in google.
Time
Something like this. match[2] will contain pattern matching
(.+?)which means anything with quantity one or more, lazy matching and located between<td class="dat">and</td>literally.