menu uit andere site (beloning: 0.27)

Gestart doorWouter15 reacties525 weergaven

16 berichten · pagina 1 van 2

Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Beste lezer(es) emo
Gaaag zou ik een script maken dat content uit een andere pagina haalt, meerbepaald de links.

Dus als er op website http://www.website.nl

<a href="index.php?p=1">Pagina 1</a><br /> 
<a href="index.php?p=2">Pagina 2</a><br /> 
<a href="index.php?p=3">Pagina 3</a><br /> 
<a href="index.php?p=5">Blabla</a><br />


staat, ik die in mijn scriptje zo krijg:

1: Pagina 1
2: Pagina 2
3: Pagina 3
5: Blabla


Ik weet dat ik op die site moet geraken d.m.v. cURL; maar hoe moet ik die inhoud ervan halen?(ereg ?)

Met vriendelijke groeten
Wouter
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Met file_get_Contents de content ophalen en met explode selecteren wat je nodig hebt smile
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Nja, maar ik moet wel 2 dingen eruithalen, en hoe ga je die explode dan scripten?
0
Berichten
1.544
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
preg_match?
0
Berichten
1.544
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/preg_match_all"]preg_match_all[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/<a href="index.php?p=[0-9]*">(.*?)</a>/[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$content[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/print_r"]print_r[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$output[/COLOR][COLOR= #007700]);[/COLOR]
?>
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Output : Array ( [0] => Array ( ) [1] => Array ( ) )
0
Berichten
1.544
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Met dit:

<a href="index.php?p=1">Pagina 1</a><br /> 
<a href="index.php?p=2">Pagina 2</a><br /> 
<a href="index.php?p=3">Pagina 3</a><br /> 
<a href="index.php?p=5">Blabla</a><br />


Als $content
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Jenner schreef:
Met dit:

<a href="index.php?p=1">Pagina 1</a><br /> 
<a href="index.php?p=2">Pagina 2</a><br /> 
<a href="index.php?p=3">Pagina 3</a><br /> 
<a href="index.php?p=5">Blabla</a><br />
Als $content

$content = file_get_contents("http://www.volledigewebsite");

heb ik, dus niet alleen het menu, maar de hele website ...
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Nah, werkt toch blijkbaar niet,

heb

$content = Pagina 1

Pagina 2

Pagina 3

Blabla
;

eens genomen en t werkt nog altijd niet ...
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Echt niemand? er hangt een beloning aan vast...
0
Berichten
251
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Even iets proberen, ben er niet zeker van.

Stel dat dit je code is(want ik heb de volledige code niet)

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//ben geen fan van forwardslashes ;) //[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Welkom bezoeker, hieronder het menu:<br />"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<div id=menu>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href=index.php?p=1>Pagina 1</a><br />"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href=index.php?p=2>Pagina 2</a><br />"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href=index.php?p=3>Pagina 3</a><br />"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href=index.php?p=5>Blabla</a><br />"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</div>"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"We hopen dat je iets vindt in het menu!"[/COLOR][COLOR= #007700];[/COLOR]
?>


Dan wordt dat in je HTML zoiets:

Welkom bezoeker, hieronder het menu:<br />
<div id="menu">
<a href="index.php?p=2">Pagina 2</a><br /> 
<a href="index.php?p=3">Pagina 3</a><br /> 
<a href="index.php?p=5">Blabla</a><br />
</div>
We hopen dat je iets vindt in het menu!


Dus je php code voor het op te halen wordt dan:
(er zit wat onnodige code in mrja haal je er maar uit)

[COLOR= #0000BB]<?php
$url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"http://www.website.nl/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$file[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$split[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]<div id="menu">[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$file[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$onder[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$split[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$split2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]</div>[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$onder[/COLOR][COLOR= #007700])[/COLOR] [COLOR= #FF8000]//je bent zeker dat het deze </div> is want die staat zowiezo eerst//
//even verzamelen//[/COLOR]

[COLOR= #0000BB]$boven[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$split[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]0[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$menu[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$split2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]0[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$onder[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$split2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]];[/COLOR]

[COLOR= #FF8000]//als je nu het menu wil tonen doe je//[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$menu[/COLOR][COLOR= #007700];[/COLOR]
?>


Als het niet werkt, weet ik het ook niet wink
0
Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
maar ik wil niet dat ik de linken zie, ik wil een overzichtje (zie startpost)
0
Berichten
251
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Die zie je hier toch niet? je ziet

Pagina 1, pagina 2, pagina3, pagina 5
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren