-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyPiScanner.cs
More file actions
48 lines (37 loc) · 1.24 KB
/
PyPiScanner.cs
File metadata and controls
48 lines (37 loc) · 1.24 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 System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net.Http;
using HtmlAgilityPack;
namespace UnsupportedPackageWriter
{
class PyPiScanner
{
string URL = "https://pypi.python.org/simple/";
public List<String> ScanPyPi()
{
string pypiHtmlPage = "";
List<string> listOfAllPypiPackages = 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();
pypiHtmlPage = task.Result;
});
json.Wait();
};
HtmlDocument pypihtml = new HtmlDocument();
pypihtml.LoadHtml(pypiHtmlPage);
HtmlNodeCollection Nodes = pypihtml.DocumentNode.SelectNodes("//a[@href]");
foreach (var link in Nodes)
{
listOfAllPypiPackages.Add(link.Attributes["href"].Value);
}
return listOfAllPypiPackages;
}
}
}