public override async Task <SnsData> LoadData(string account) { try { var data = new AmebloData() { Account = account }; var document = await BrowsingContext .New(Configuration.Default.WithDefaultLoader()) .OpenAsync(data.ProfileUri.ToString()); data.DisplayName = document.QuerySelector("title").TextContent; data.ProfileImage = await GetBitmap( document.QuerySelector("#profile > div > div.skin-widgetBody > div.skin-profile > div > a > img") .Attributes["src"].Value); data.QrCodeImage = QrCreator.Create(data.ProfileUri.ToString(), Resources.AmebaLogo); return(data); } catch (Exception e) { Debug.WriteLine(e); return(null); } }
public virtual async Task <SnsData> LoadData(string account) { if (string.IsNullOrEmpty(account)) { return(null); } try { var data = new T { Account = account }; var document = await BrowsingContext .New(Configuration.Default.WithDefaultLoader()) .OpenAsync(data.ProfileUri.ToString()); var meta = document.QuerySelectorAll("head > meta"); data.DisplayName = meta.First(x => x.HasAttribute("property") && x.Attributes["property"].Value == "og:title") .Attributes["content"].Value; data.ProfileImage = await GetBitmap(meta .First(x => x.HasAttribute("property") && x.Attributes["property"].Value == "og:image").Attributes["content"].Value); data.QrCodeImage = QrCreator.Create(data.ProfileUri.ToString(), data.LoadImage()); return(data); } catch (Exception e) { Debug.WriteLine(e); return(null); } }
public override async Task <SnsData> LoadData(string account) { try { var data = new TwitterData { Account = account }; var parser = new HtmlParser(); var html = await Client.GetStringAsync(data.ProfileUri.ToString()); var document = await parser.ParseAsync(html); var img = document.QuerySelector(".ProfileAvatar-image"); data.DisplayName = img.Attributes["alt"].Value; data.ProfileImage = await GetBitmap(img.Attributes["src"].Value); data.QrCodeImage = QrCreator.Create(data.ProfileUri.ToString(), Resources.TwitterLogo); return(data); } catch (Exception e) { Debug.WriteLine(e); return(null); } }