-1

Allow me to explain what i need after the set of code

           <tr>
<td align="center"><a href="search.asp?keyword=1123">1123</a></td>
<td> </td>
<td> </td>
<td> </td>
<td align="center"><a href="member.asp?t_id=75481&amp;t=0"></a> TEXT</td>
          </tr>

There are multiple Rows I'm trying to CURL, the link on the last t_id=75481 , is actually the ROW number. I would like to extract it based on the first

example as below

IF first = NUMBER(1123) , retrieve the number 75481 (aka CLICK in CURL).

What i'm doing here is trying to click/submit(CURL) on a text that contains the row number but i have to do that based on the comparison of my number to the first

I'm using PHP Simple HTML DOM Parser in SourceForge.It Seems limited to what i can do at times, in fact when i use it to extract some data , it doesn't seem to be able to take in enough "Conditions" which lead me to extracting the correct data half the time because website changes for different page(it does, depends on the content)

1) I would need a suggestion to get the row ID so i can CURL(act as a CLICK) 2) Any other HTML DOM you would suggest? I feel restricted or i'm just noob :x

thanks in advance!

CodeGuru
  • 3,645
  • 14
  • 55
  • 99

1 Answers1

1

You can use DOMDocument and XPath together to achieve what your trying to accomplish.

$doc = new DOMDocument();
$doc->loadHTMLFile($htmlfile);

$xpath = new DOMXpath($doc);
$elements = $xpath->query("//table/tr/1");
DevZer0
  • 13,433
  • 7
  • 27
  • 51
  • Okay, i will read about xPath. Do you have any suggestion for any other DOM or the one i'm using is good to do most stuff? I have issue extracting data correctly because the extract needs to be very specific, to the point of CLASS and Depth etc – CodeGuru Jun 29 '13 at 14:05
  • I always use the `DOMDocument` and `DOMXPath` i haven't used the simple.dom.parser. So i am afraid i can't comment on it. `XPath` is gold you should try to use it. – DevZer0 Jun 29 '13 at 14:07
  • xPath is GOd! I can copy from Source the xpath, DONE. What is DOMDcoument for then? Since xpath is so useful? To make it readable for xpath? by the way, what if the page loads differently, small part, is there a way to extract? maybe a if else in xpath or something like that? or extract text only? – CodeGuru Jun 29 '13 at 16:25
  • and anyway to do something like this? foreach in UL,LI,A tag – CodeGuru Jun 29 '13 at 16:26