开发者

Table/Page manipulation using php

i) I have a page with three columns.

Say the page is of the form:

A B C

1 4 7

2 5 8

3 6 9

A, B, C are for illustrative purposes.

I need to download only 4,5,6. The links do not have a开发者_如何学Gony similarities and do not follow any pattern.

ii) Each column has n number of links.

iii) I need to download or print all the links of the second column.

How should I do that using html dom parser? I am able to print all the links.


Your question doesn't provide very much information. Say your page is rendered in a browser that supports javascript, your columns are DIV tags and you can also use javascript on the page, you could select the links using jQuery.

var links = [];
$('#columnB a').each(function(index){ // Assuming columnB is the ID of your middle column.
  links.push($(this).href);
});

And then pass your variable links to PHP using an XmlHttpRequest.

If your page is just an HTML file, you need to use an SGML (for HTML) or an XML (for XHTML) parser. In case you are having XHTML in a file, have a look at XPATH, and the functionality that PHP has for it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜