-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBioconductorScanner.cs
More file actions
48 lines (39 loc) · 1.5 KB
/
BioconductorScanner.cs
File metadata and controls
48 lines (39 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
namespace UnsupportedPackageWriter
{
class BioconductorScanner
{
string URL = "https://www.bioconductor.org/packages/release/bioc/";
public List<String> ScanBioconductor()
{
string cranHtmlPage = "";
List<string> listOfAllCranPackages = new List<string>();
using (HttpClient hc = new HttpClient())
{
var json = hc.GetAsync(URL).ContinueWith((taskwithresponse) =>
{
var response = taskwithresponse.Result;
var task = response.Content.ReadAsStringAsync();
task.Wait();
cranHtmlPage = task.Result;
});
json.Wait();
};
HtmlDocument cranHtml = new HtmlDocument();
cranHtml.LoadHtml(cranHtmlPage);
string innerHtml = cranHtml.GetElementbyId("PageContent").SelectSingleNode("//div[last()]").SelectSingleNode("//table").InnerHtml;
HtmlDocument bioconductorListHtml = new HtmlDocument();
bioconductorListHtml.LoadHtml(innerHtml);
HtmlNodeCollection nodes = bioconductorListHtml.DocumentNode.SelectNodes("//a[@href]");
foreach (var link in nodes)
{
listOfAllCranPackages.Add(link.InnerHtml);
}
return listOfAllCranPackages;
}
}
}