|
-
Apr 9th, 2024, 02:08 PM
#1
Thread Starter
Frenzied Member
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/
-
Apr 9th, 2024, 03:46 PM
#2
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
-
Apr 10th, 2024, 09:31 AM
#3
Thread Starter
Frenzied Member
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.
-
Apr 10th, 2024, 12:00 PM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|