Skip to content

Instantly share code, notes, and snippets.

@mayur-tendulkar
Created July 11, 2018 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayur-tendulkar/2f524b373a05a45ffec12ac356fc68e5 to your computer and use it in GitHub Desktop.
Save mayur-tendulkar/2f524b373a05a45ffec12ac356fc68e5 to your computer and use it in GitHub Desktop.
AZR-ListAllAzureServicesNew
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Fetching service listing...");
Console.ReadKey();
Task.Run(async () => FetchRecords());
Console.ReadKey();
}
static async void FetchRecords()
{
var client = new HttpClient();
var data = await client.GetStringAsync("https://azure.microsoft.com/en-us/services/");
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(data);
var node = doc.DocumentNode.SelectNodes("//div").ToList();
var listOfServices = new List<AzureServices>();
var lb = new StringBuilder();
foreach (var item in node)
{
if (item?.Attributes["class"]?.Value == "column medium-6 end")
{
var service = new AzureServices();
var a = item.SelectNodes("a").FirstOrDefault();
service.ServiceName = a.InnerText;
service.ServiceURL = a.Attributes["href"].Value;
lb.AppendLine(service.ServiceName + ", https://azure.microsoft.com" + service.ServiceURL);
listOfServices.Add(service);
}
}
var file = System.IO.File.Create(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"AzureListing1.txt"));
file.Close();
File.WriteAllText(file.Name, lb.ToString());
file.Close();
}
}
public class AzureServices
{
public string ServiceName { get; set; }
public string ServiceURL { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment