Hello you both! good evening hcvv and mmarif4u! great to see you!!
@both, hcvv and mmarif4u!: agreed - i will write more precisely in the future!
Hmmm - i am not sure about your question. I will write down what is aimed and what i have done! Perhaps this clears up a bit the code.
What is aimed: Hmmm - i want to automize the integration of many urls, that are build in a quite simple way…in order to build in the URLs into a parser-script.
What happened: i runned the code that is shown below (see the code at the end of this posting) - and got the following error:
martin@suse-linux:~/perl> php parser_rlpa.php
PHP Parse error: syntax error, unexpected ';' in /home/martin/perl/parser_rlpa.php on line 9
Again **What is aimed!: ** well i am creating a little parser:
This is a complete URL: Schulen in Rheinland-Pfalz: Einzelanzeige
As i have many URLs to parse i have the **divided URL into two pieces: **
**part one: **
http://schulen.bildung-rp.de/gehezu/startseite/einzelanzeige.html?tx_wfqbe_pi1%5buid%5d=
**part two: ** with the the following endings:
60452
60512
60329
60149
60239
60436
60569
62135
60422
60616
…and so forth …[note i have many many of those endings of the URL; In order to parse the corresponding sites i subsequently want to [b]load the full URLs into the parser-script you see below.
Again - in other words: ** I thought that i have to take the first part of the URL, i call it the base-URL **
http://schulen.bildung-rp.de/gehezu/startseite/einzelanzeige.html?tx_wfqbe_pi1%5buid%5d=
…and the second part - the endings 62135, 60422, 60616 [and so forth]- and combine them in a concatenation - with a DOT-Operator. But again: as mentioned above: i runned the code and i got the error:
martin@suse-linux:~/perl> php parser_rlpa.php
PHP Parse error: syntax error, unexpected ';' in /home/martin/perl/parser_rlpa.php on line 9
See the code that i runned:
<?php
$dom = new DOMDocument();
$orig_string = "http://schulen.bildung-rp.de/gehezu/startseite/einzelanzeige.html?tx_wfqbe_pi1%5buid%5d=";
@$dom->loadHTMLFile {
$number_array = array ( "60089", "60152","60242","61730", "43567", "9287","3323");
for($i=0; $i<$count($number_array); $i ++) {
$new_url = $orig_url . $number_array$i];
/* do something with the new url */
}
$divElement = $dom->getElementById('wfqbeResults');
$innerHTML= '';
$children = $divElement->childNodes;
foreach ($children as $child) {
$innerHTML = $child->ownerDocument->saveXML( $child );
$doc = new DOMDocument();
$doc->loadHTML($innerHTML);
//$divElementNew = $dom->getElementsByTagName('td');
$divElementNew = $dom->getElementsByTagname('td');
/*** the array to return ***/
$out = array();
foreach ($divElementNew as $item)
{
/*** add node value to the out array ***/
$out] = $item->nodeValue;
}
echo '<pre>';
print_r($out);
echo '</pre>';
}
?>
Hmm _ guess that i have done something wrong here! I will think about this code. There must be an error in line 9. Perhaps i have written something wrong while i integrated the array with the numbers…
Any and all help will be greatly appreciated
Regards
db1:)
Post Scriptum: Note, see the results of a single URL - without any loop and array:
pre>Array
(
[0] => Schulart:
[1] => BBS
[2] => Schulnummer:
[3] => 60119
[4] => Anschrift:
[5] => Berufsbildende Schule BoppardAntoniusstr. 2156154 Boppard
[6] => Telefon:
[7] => (0 67 42) 80 61-0
[8] => Telefax:
[9] => (0 67 42) 80 61-29
[10] => E-Mail:
[11] => sekretariat@bbs-boppard.de
[12] => Internet:
[13] => http://www.bbs-boppard.de
[14] => Träger:
[15] => Kreisverwaltung Rhein-Hunsr�ck-Kreis
[16] => letzte Ãnderung:
[17] => 08 Feb 2010 14:33:12 von 60119
)
This nice result is the output of the following code: It is a solution that returns the labels and values in a formatted array ready for input to mysql. Very nice;-)
<?php
$dom = new DOMDocument();
@$dom->loadHTMLFile('http://schulen.bildung-rp.de/gehezu/startseite/einzelanzeige.html?tx_wfqbe_pi1%5buid%5d=60119');
$divElement = $dom->getElementById('wfqbeResults');
$innerHTML= '';
$children = $divElement->childNodes;
foreach ($children as $child) {
$innerHTML = $child->ownerDocument->saveXML( $child );
$doc = new DOMDocument();
$doc->loadHTML($innerHTML);
//$divElementNew = $dom->getElementsByTagName('td');
$divElementNew = $dom->getElementsByTagname('td');
/*** the array to return ***/
$out = array();
foreach ($divElementNew as $item)
{
/*** add node value to the out array ***/
$out] = $item->nodeValue;
}
echo '<pre>';
print_r($out);
echo '</pre>';
}
?>