hello dear S.dot,
Many thanks for the reply. I want to load the numbers into an array: like so:
Code: Select all
$orig_string = "http://www.somesite.com?page=";
$number_array = array ("123", "43567", "9287","3323");
for($i=0; $i<$count($number_array); $i ++) {
$new_url = $orig_url . $number_array[$i];
/* do something with the new url */
}
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.
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:
Code: Select all
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
...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
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
Code: Select all
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:
Code: Select all
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:
Code: Select all
<?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....
S.dot [and all]: Any and all help will be greatly appreciated
Regards
lin
Post Scriptum: Note, see the results of a
single URL - without any loop and array:
Code: Select all
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;-)
Code: Select all
<?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>';
}
?>
Question is: how to integrate the above mentioned code:
Code: Select all
$orig_string = "http://www.somesite.com?page=";
$number_array = array ("123", "43567", "9287","3323");
for($i=0; $i<$count($number_array); $i ++) {
$new_url = $orig_url . $number_array[$i];
/* do something with the new url */
}