开发者

Parse text from an HTML page

开发者 https://www.devze.com 2023-01-03 05:48 出处:网络
I know it is possible to get information (text) from another page. Fo开发者_StackOverflow社区r example, on the page at http://www.page.com/ is a div named news.

I know it is possible to get information (text) from another page.

Fo开发者_StackOverflow社区r example, on the page at http://www.page.com/ is a div named news. How can I get the text from this div?


Yes, that's what HTML Simple DOM is for amongst other options.

Example:

$html  = file_get_html('http://www.page.com/');
$mydiv = $html->find('div[id=news]', 0)->plaintext;


Use an HTML parser.

0

精彩评论

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