Example #1
0
        private async Task <string> GetPhoto(IElementHandle element)
        {
            var photoTag = await element.QuerySelectorAsync("img.gs-image");

            if (photoTag != null)
            {
                return(await photoTag.EvaluateAsync <string>("e => e.getAttribute('src')"));
            }
            else
            {
                return(string.Empty);
            }
        }
Example #2
0
        private async Task <TEntity> GetDataAsync(IElementHandle element)
        {
            var entity = new TEntity();

            var title = await element.QuerySelectorAsync("a.gs-title");

            if (title == null)
            {
                return(entity);
            }

            entity.Url = await title.EvaluateAsync <string>("e => e.getAttribute('href')");

            var innerText = await element.EvaluateAsync <string>("e => e.innerText");

            entity.Description = innerText;
            entity.Photo       = await GetPhoto(element);

            return(entity);
        }
Example #3
0
 public static Task <Result <IElementHandle, Error> > QuerySelector(this IElementHandle elementHandle, string selector) =>
 from result in elementHandle.QuerySelectorAsync(selector)
 select result is not null
     ? Ok <IElementHandle, Error>(result)