Example #1
0
        public static async Task <string> FindArticle(string doi)
        {
            var scihub = await FindAddress();

            string text;

            try
            {
                text = await WebUtility.SimpleTextRequest(WebUtility.BuildUrl(scihub, doi));
            }
            catch (Exception e)
            {
                throw new SciHubException(SciHubExceptionType.Availability, e);
            }

            var doc = new HtmlDocument();

            doc.LoadHtml(text);
            var iframe = doc.GetElementbyId("pdf");

            if (iframe != null)
            {
                var src = iframe.GetAttributeValue("src", string.Empty);
                if (src.StartsWith("//"))
                {
                    src = "https:" + src;
                }
                return(src);
            }
            throw new SciHubException(SciHubExceptionType.Article);
        }