Scrape on Ajax - Wait until element exist

veeco

Client
Регистрация
27.05.2011
Сообщения
112
Благодарностей
1
Баллы
18
Hello,
i would like to know if it possible to scrape ajax content with projectMaker. The idea is to wait until element exist, then begin scraping.

Thanks
 

veeco

Client
Регистрация
27.05.2011
Сообщения
112
Благодарностей
1
Баллы
18

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113
There's ready snippet in link above.

If you wanna use php you can do it only in CodeCreator.
 

mtantouri

Client
Регистрация
11.08.2013
Сообщения
32
Благодарностей
1
Баллы
8
Will this code loop itself until it finds the element? What if the page return as server code 5xx error, what happens then?
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113

mtantouri

Client
Регистрация
11.08.2013
Сообщения
32
Благодарностей
1
Баллы
8
Yes that one. But what if the server return an 502 error and it didn't find the element, how can I know. Am I missing something on that thread?
 

mtantouri

Client
Регистрация
11.08.2013
Сообщения
32
Благодарностей
1
Баллы
8
Im using btw:

Код:
HtmlElement he;
for(int i=0;i<20;i++)
{
    he = instance.ActiveTab.FindElementByAttribute("Your data in parameters");
    if(!he.IsVoid)
    {
        break;
    }
    System.Threading.Thread.Sleep(2000);
}
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113
this code doesnt have in-built logic and it will be succesful in 100% of cases. you need to throw error if element is not found?
 

mtantouri

Client
Регистрация
11.08.2013
Сообщения
32
Благодарностей
1
Баллы
8

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113
Код:
HtmlElement he;
bool found = false;
for(int i=0;i<20;i++)
{
    he = instance.ActiveTab.FindElementByAttribute("Your data in parameters");
    if(!he.IsVoid)
    {
        found = true; break;
    }
    System.Threading.Thread.Sleep(2000);
}
if (!found) throw new Exception("not found");
 

mtantouri

Client
Регистрация
11.08.2013
Сообщения
32
Благодарностей
1
Баллы
8
You are the best. Thanks, it works great.
 

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