Jump to content

Need help with extracting links


komirad

Recommended Posts

The links in the html looks something like this, with many iterations:

 

<h2 class="lists">Section Name(variable1)</h2>

<ul class="listings">

<li><a href="variable2" title="variable3">variable4</a></li>
<li><a href="variable2" title="variable3">variable4</a></li>
<li><a href="variable2" title="variable3">variable4</a></li>
<li><a href="variable2" title="variable3">variable4</a></li>

</ul>

 

I need the links to be seperated by the section name.

So the result array would be something like this, with each item contain the details of the link such as the title, url and anchor text:

 

Section 1:

link1, link2, link3

Section 2:

link1, link2, link3

 

 

 

I managed to extract the links, but I couldn't find to list them according to their Sections with the following code:

preg_match_all('/href="([^"]+)"[^>]*>([^<]+)/',$pageCode,$resultArray);

 

Any help? :D

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.