Results 1 to 4 of 4

Thread: Urlscan.io API

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    1,975

    Urlscan.io API

    I know this is probably a long shot, but has anyone here ever used the urlscan.io API in VB.net? I want to do a search by passing my search parameters & get back the results.
    I'm having trouble figuring out how to code it. I have an API key already. Any help would be greatly appreciated.

    Here is link to the API docs:
    https://urlscan.io/docs/api/

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,801

    Re: Urlscan.io API

    I haven't, but it seems fairly straight forward. Submit a REST request and do something with the response.

    For example, taking the Submission API example from the link you provided:
    Code:
    ' declaration
    Private Async Function PostUrlScanAsync(apiKey As String, urlToScan As String, tags As IEnumerable(Of String)) As Task(Of String)
        Using client = New HttpClient()
            client.DefaultRequestHeaders.Add("API-Key", apiKey)
    
            Dim requestUri = "https://urlscan.io/api/v1/scan/"
            Dim payloadObject = New With {
                Key .url = urlToScan,
                Key .visibility = "public",
                Key .tags = tags
            }
            Dim payload = JsonConvert.SerializeObject(payloadObject)
            Dim content = New StringContent(payload, Encoding.UTF8, "application/json")
            Dim response = Await client.PostAsync(requestUri, content)
    
            If (response.IsSuccessStatusCode) Then
                Return Await response.Content.ReadAsStringAsync()
            End If
    
            Throw New HttpRequestException($"Request failed with status code {response.StatusCode} and message: {response.ReasonPhrase}")
        End Using
    End Function
    
    ' usage
    Try
        Dim result = Await PostUrlScanAsync("your_api_key_here", "https://scan-this-url.com")
        Console.WriteLine(result)
    Catch ex As Exception
        Console.WriteLine(ex.Message)
    End Try
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    1,975

    Re: Urlscan.io API

    dday ... thanks for the reply. I'm trying your code example but getting hung up on a JsonConvert error, saying it is not declared. Are you using NewtonSoft for this?
    Last edited by nbrege; Apr 10th, 2024 at 09:40 AM.

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,801

    Re: Urlscan.io API

    Yes, I'm using Newtonsoft. However, you could also use System.Text.Json:
    Code:
    Dim options As New JsonSerializerOptions With {
        .PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
        .WriteIndented = True
    }
    
    Dim payload = JsonSerializer.Serialize(payloadObject, options)
    I've just used Newtonsoft for so long that it's sort of my go to.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width