bitwizardry

Baixando matrizes do repositório La Jolla

Recommended Posts

Posted (edited)

Bom dia amigos,

 

Desenvolvi uma simples função em .NET que retorna a matriz do repositório La Jolla apenas inserindo os parâmetros.

Se alguém estiver interessado, esse é o código:

 

vb.NET

 

    Public Shared Function LaJollaCovering(v As Integer, k As Integer, t As Integer) As String

        ' - http://www.dmgordon.org/cover/

        Dim c() As String = {"v=" & v.ToString, "k=" & k.ToString, "t=" & t.ToString}
        Dim url As String = "http://ljcr.dmgordon.org/show_cover.php?" & String.Join("&", c)
        Dim web = New HtmlAgilityPack.HtmlWeb()
        Dim doc = web.Load(url)
        Dim htmlNodes = doc.DocumentNode.SelectNodes("//body/pre")

        Return htmlNodes.Nodes.First.InnerText

    End Function

 

C#

 

    public static string LaJollaCovering(int v, int k, int t)    {

        // - http://www.dmgordon.org/cover/

        string[] c = {"v=" + v.ToString(), "k=" + k.ToString(), "t=" + t.ToString()};
        string url = "http://ljcr.dmgordon.org/show_cover.php?" + string.Join("&", c);
        var web = new HtmlAgilityPack.HtmlWeb();
        var doc = web.Load(url);
        var htmlNodes = doc.DocumentNode.SelectNodes("//body/pre");

        return htmlNodes.Nodes.First.InnerText;

    }

 

É necessário instalar o Html Agility Pack: https://www.nuget.org/packages/HtmlAgilityPack/

A função retorna a matriz em texto simples, para manipulá-la é preciso fazer o split entre as linhas e depois entre os elementos.

 

 

Edited by bitwizardry
  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.