A
A
Alexey2014-08-11 16:00:52
PHP
Alexey, 2014-08-11 16:00:52

Cut out a necessary piece from a web page?

The situation is this:
I'm using Simple HTML DOM.
Given:

$result = simple_html_dom т.е. html код всей страницы
$selector = 'div.column_1.column_3'

Required:
Cut $result into 3 parts where:
1st part - before $selector = 'div.column_1.column_3'
2nd part - $selector = 'div.column_1.column_3'
3rd part - after $selector = 'div.column_1.column_3 '

Tell me how to do this?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Reistlin, 2014-08-11
@azovl

Part 2 is most likely $html->find('div.column_1.column_3');, and 1 and 3 are unlikely to succeed with this library (unless these next_sibling() and prev_sibling() methods, although it is unlikely ) better with regex

S
Sergey, 2014-08-11
@butteff

You can use this library: simplehtmldom.sourceforge.net
and take only what you need at once, without splitting.
And if you still answer your question, then these are regular expressions and nothing better than them.
Read "regular expressions" and functions for working with them, for example preg_match()

A
Alexey, 2014-08-11
@azovl

butteff, if you carefully look at my question, then I indicated it there. I will most likely use regular expressions, but inside, there is already a library to change.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question