من براتون تست کردم .
اینستاگرام چون با React JS نوشته شده ، کدهای داخل react-root وقتی که از HttpRequest استفاده میکنید نمایش داده نمیشن و null برگردونده میشه و بخاطر همین نمیتونید از XPath و HtmlAgilityPack استفاده کنید.
روش دیگه ای پیدا کردم و یک Sample براتون ساختم که میتونید استفاده کنید ازش :
static void Main()
{
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
Stream data = client.OpenRead("https://www.instagram.com/hossein_mnt/");
if (data != null)
{
using (StreamReader reader = new StreamReader(data))
{
Regex regex1 = new Regex(@"(.*)\.jpg");
Regex regex2 = new Regex(@"(?<=https)(.*)(?=)");
string s = reader.ReadToEnd();
MatchCollection findImage = regex1.Matches(s);
string profileImageElement = findImage
.OfType<Match>()
.Select(m => m.Value)
.Distinct()
.FirstOrDefault();
if (profileImageElement != null)
{
MatchCollection profileImageUrl = regex2.Matches(profileImageElement);
string finalResult = profileImageUrl
.OfType<Match>()
.Select(m => m.Value)
.Distinct()
.FirstOrDefault();
Console.WriteLine("https" + finalResult);
}
Console.ReadKey();
}
}
}