Stukje uit bron kopieeren
http://www.moppen.nu/cgi-bin/moppen.cgi?id=1 staat een textarea (met de naam text) waarin de mop van de dag staat.
Is het mogelijk om die textarea uit de bron (met file_get_content dacht ik) te halen, en die weer te geven?
Ik zit met een probleem, op de site Is het mogelijk om die textarea uit de bron (met file_get_content dacht ik) te halen, en die weer te geven?
Ja dat kan maar dat is vrij inefficient denk ik.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
<?php
$file = file('http://www.moppen.nu/cgi-bin/moppen.cgi?id=1');
foreach($file as $line_num => $line){
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line){
preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line, $output);
preg_match('/</textarea>/', $output[3], $output);
$finalOutput = $output[1];
}
}
echo $finalOutput;
?>
$file = file('http://www.moppen.nu/cgi-bin/moppen.cgi?id=1');
foreach($file as $line_num => $line){
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line){
preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line, $output);
preg_match('/</textarea>/', $output[3], $output);
$finalOutput = $output[1];
}
}
echo $finalOutput;
?>
zo zou ie denk ik moeten werken.
Parse error: syntax error, unexpected '{' in C:\Webserver\UsbWebserver\Root\mop.php on line 4
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line)){
Hoe wil je die tekst weergeven? Het kan ook met JavaScript namelijk.
brie schreef op 21.04.2008 20:13:
regel 4 wordt:
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line)){
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line)){
Dan krijg ik de volgende fout:
Notice: Undefined offset: 3 in C:\Webserver\UsbWebserver\Root\mop.php on line 7
Warning: preg_match() [function.preg-match]: Unknown modifier 't' in C:\Webserver\UsbWebserver\Root\mop.php on line 7
Notice: Undefined offset: 1 in C:\Webserver\UsbWebserver\Root\mop.php on line 8
Gewijzigd op 01/01/1970 01:00:00 door Thijn
regel 7:
preg_match('|</textarea>|', $output[3], $output);
EDIT:
zo moet ie werken (getest)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$file = file('http://www.moppen.nu/cgi-bin/moppen.cgi?id=1');
foreach($file as $line_num => $line){
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line)){
preg_match('|^(.*)(<textarea name=text rows=5 cols=40 wrap=auto>)(.*)$|', $line, $output);
preg_match('|^(.*)(</textarea>)(.*)$|', $output[3], $output);
$finalOutput = $output[1];
}
}
echo $finalOutput;
?>
$file = file('http://www.moppen.nu/cgi-bin/moppen.cgi?id=1');
foreach($file as $line_num => $line){
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line)){
preg_match('|^(.*)(<textarea name=text rows=5 cols=40 wrap=auto>)(.*)$|', $line, $output);
preg_match('|^(.*)(</textarea>)(.*)$|', $output[3], $output);
$finalOutput = $output[1];
}
}
echo $finalOutput;
?>
Gewijzigd op 01/01/1970 01:00:00 door Boris Mattijssen
Notice: Undefined offset: 3 in C:\Webserver\UsbWebserver\Root\mop.php on line 7
Notice: Undefined offset: 1 in C:\Webserver\UsbWebserver\Root\mop.php on line 8
EDIT:
Bedankt!
Gewijzigd op 01/01/1970 01:00:00 door Thijn
Nog even de JavaScript oplossing, voor de volledigheid ;-)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$file = file('http://www.moppen.nu/cgi-bin/moppen.cgi?id=1');
foreach($file as $line_num => $line){
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line)){
preg_match('|^(.*)(<textarea name=text rows=5 cols=40 wrap=auto>)(.*)$|', $line, $output);
echo "<pre>".print_r($output, TRUE)."</pre>";
preg_match('|^(.*)(</textarea>)(.*)$|', $output[3], $output);
$finalOutput = $output[1];
}
}
//echo $finalOutput;
?>
$file = file('http://www.moppen.nu/cgi-bin/moppen.cgi?id=1');
foreach($file as $line_num => $line){
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line)){
preg_match('|^(.*)(<textarea name=text rows=5 cols=40 wrap=auto>)(.*)$|', $line, $output);
echo "<pre>".print_r($output, TRUE)."</pre>";
preg_match('|^(.*)(</textarea>)(.*)$|', $output[3], $output);
$finalOutput = $output[1];
}
}
//echo $finalOutput;
?>
Wat geeft die terug?
Djemo schreef op 21.04.2008 20:43:
Wat geeft die terug?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$file = file('http://www.moppen.nu/cgi-bin/moppen.cgi?id=1');
foreach($file as $line_num => $line){
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line)){
preg_match('|^(.*)(<textarea name=text rows=5 cols=40 wrap=auto>)(.*)$|', $line, $output);
echo "<pre>".print_r($output, TRUE)."</pre>";
preg_match('|^(.*)(</textarea>)(.*)$|', $output[3], $output);
$finalOutput = $output[1];
}
}
//echo $finalOutput;
?>
$file = file('http://www.moppen.nu/cgi-bin/moppen.cgi?id=1');
foreach($file as $line_num => $line){
if(preg_match('/<textarea name=text rows=5 cols=40 wrap=auto>/', $line)){
preg_match('|^(.*)(<textarea name=text rows=5 cols=40 wrap=auto>)(.*)$|', $line, $output);
echo "<pre>".print_r($output, TRUE)."</pre>";
preg_match('|^(.*)(</textarea>)(.*)$|', $output[3], $output);
$finalOutput = $output[1];
}
}
//echo $finalOutput;
?>
Wat geeft die terug?
Ik heb al een oplossing, maar bedankt voor de moeite!