Jump to content

loop in a little parser script - how to itterate over several urls


dilbertone

Recommended Posts

good day dear freaks

 

i want to parse the site - and get the results out of it:

 

see this third overview-page

 

 

 

therefore i need to loop over the line 2 - don ´ i!?

 


<?php
$data = file_get_contents('http://www.educa.ch/dyn/79363.asp?action=search');
$regex = '/Page 1 of (.+?) results/';
preg_match($regex,$data,$match);
var_dump($match);
echo $match[1];
?>

 

in order to get the details of the pages -

 

see this first detail-page

 

see this second detail-page

 

 

see this third detail-page

 

 

 

just help me with this seven-liner  ;)

Link to comment
Share on other sites

Only one issue with your first line, and that is: file_get_contents will parse that URL into 1 single string, so your script wouldn't function anyway, I think that file() would be the better option as this will read the contents into an array, as for the rest of the logic, I'm not too sure what your trying to achieve, unless it's a sort of pagination??

 

Probably missed the point to the question; my apologies if I have..

 

Rw

Link to comment
Share on other sites

hi there hello dear rwwd

 

i want to reconstruct the sub-page URLs.  see here :

 

http://www.educa.ch/dyn/79363.asp?action=search

 

for($i=1;$i<=$match[1];$i++)
{
  $url = "http://www.example.com/page?page={$i}";
  // access new sub-page, extract necessary data
}

 

well this is what i want to. And now i need to have a good parser-script.

 

Note:  this is a tree-part-job:

 

1-. fetching the sub-pages

2. parsing them

3. storing the data in a mysql-db

 

 

btw- parsing should be a part that can be done with DomDocument - What do you think?

I need to combine the first part with tthe second - can you give me some starting points and hints to get this

 

fetching-job done - and to process the data into a DomDocument-Parser-Job.

 

I would love to discuss this with you here...  Look  forward to hear from you rwwd

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.