Taking some content with regex from couple of html lines.

intruder2600

Client
Регистрация
15.12.2011
Сообщения
47
Благодарностей
1
Баллы
6
Hi,

There is no problem to take some content from page with regex from one line like this:

Код:
<li><a href="http://www.url.com">anchor</a></li>
It will go like this:
(?<=<li><a\ href="http://www\.url\.com">).*(?=</a></li>)

But what about situation, where I need to take content from couple of html lines:


Код:
<input type="text" value="search" id="searchInput" name="query" class="">
						<div id="searchSelector"> 
                                                <a href="http://www.url.com">anchor</a>
						<div id="searchSelBtn"></div>
					</div>
I need to take content located between:

<input type="text" value="search" id="searchInput" name="query" class="">
<div id="searchSelector">
<a href="http://www.url.com">

and:

</a>
<div id="searchSelBtn"></div>
</div>[/CODE]


This is just an example. I need to use more lines, because there is more of same code on website, so I need to take more html to get this one, which I need.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 706
Баллы
113
If you cannot create one regex to scrape data that you need, you can perform several steps: scrape tiny blocks of codes that you can exclud with regex and store them in lists, then create a loop: take line , extract needed data from there, put to other list...
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 770
Благодарностей
1 180
Баллы
113
Регистрация
31.07.2012
Сообщения
99
Благодарностей
14
Баллы
8

intruder2600

Client
Регистрация
15.12.2011
Сообщения
47
Благодарностей
1
Баллы
6
Thanks alot for answers :-)
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)