Forum Xamarin.Forms

Grabbing Website Title is too slow

JassimRahmaJassimRahma USMember ✭✭✭✭

Hi,

I am using below code to grab website title and I also want later to grab the website photo(s) just like what Fcebook, linkedin and twitter is doing

The problem I facing here that it is too slow and takes very long time to show the title unlike when you do it using facebook or linkedin for example

How can I fix that please?

private async void Button_Clicked(object sender, EventArgs e)
{
    LabelWebsiteURL.Text = EntryURL.Text;

    HttpClient hc = new HttpClient();
    HttpResponseMessage response = await hc.GetAsync(new Uri(LabelWebsiteURL.Text, UriKind.Absolute));
    string source = await response.Content.ReadAsStringAsync();

    string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;

    LabelWebsiteTitle.Text = title;
}

Thanks,
Jassim

Sign In or Register to comment.