Exemplo n.º 1
0
        public async Task <AuthorQuote> TranslateQuote(AuthorQuote quote, string language)
        {
            var text = await _azureTranslate.Translate(quote.Quote, language);

            quote.Quote = text;

            return(quote);
        }
Exemplo n.º 2
0
        public async Task <AuthorQuote> GetDailyQuote()
        {
            // Asynchronously get the document in a new context using the configuration
            string url      = "https://www.goodreads.com/quotes";
            var    document = await BrowsingContext.New(_angleConfig).OpenAsync(url);

            // This CSS selector gets the desired content
            var quoteSelector = "#quoteoftheday > div.stacked.mediumText > i";

            var authorSelector = "#quoteoftheday > div.textRight > strong > div > a";

            var quote = new AuthorQuote();

            quote.Quote  = document.QuerySelector(quoteSelector).TextContent;
            quote.Author = document.QuerySelector(authorSelector).TextContent;

            return(quote);
        }
        public async Task <AuthorQuote> Get(AuthorQuote quote)
        {
            var translatedquote = await _quoteService.TranslateQuote(quote, quote.LanguageCode);

            return(translatedquote);
        }