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
https://forums.phpfreaks.com/topic/166148-need-help-with-extracting-links/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.