vb.net 用户输入 url
vb.net user input into url
我目前正在制作一个 VB.net 控制台应用程序,它调用基于 Web 的 API 将结果返回到控制台。
我想做的是让用户自己输入IP。
Dim sURL As String
sURL = "http://api.hackertarget.com/geoip/?q=1.1.1.1"
我希望能够用用户输入替换 1.1.1.1
谢谢
编辑:
当我运行程序时我需要在控制台中插入两次IP
Dim nL As String = Environment.NewLine
Console.Write("Please enter an IP Address: ")
Dim input = Console.ReadLine()
这是我用来接受用户输入的代码
编辑2:
完整代码
Imports System
Imports System.Net
Imports System.IO
Module Module1
Sub Main()
IP:
Dim nL As String = Environment.NewLine
Console.Write("Please enter an IP Address: ")
'Console.WriteLine()
Dim input = Console.ReadLine()
Dim sURL As String
sURL = "http://api.hackertarget.com/geoip/?q=1.1.1.1".Replace("1.1.1.1", Console.ReadLine())
Dim wrGETURL As WebRequest
wrGETURL = WebRequest.Create(sURL)
Dim myProxy As New WebProxy("myproxy", 80)
myProxy.BypassProxyOnLocal = True
Dim objStream As Stream
objStream = wrGETURL.GetResponse.GetResponseStream()
Dim objReader As New StreamReader(objStream)
Dim sLine As String = ""
Dim i As Integer = 0
Do While Not sLine Is Nothing
i += 1
sLine = objReader.ReadLine
If Not sLine Is Nothing Then
Console.WriteLine("{0}:{1}", i, sLine)
End If
Loop
Console.ReadLine()
GoTo IP
End Sub
模块结束
你应该使用 -
Dim sURL As String
Console.Write("Please enter an IP Address: ")
sURL = "http://api.hackertarget.com/geoip/?q=1.1.1.1".Replace("1.1.1.1", Console.ReadLine())
我目前正在制作一个 VB.net 控制台应用程序,它调用基于 Web 的 API 将结果返回到控制台。 我想做的是让用户自己输入IP。
Dim sURL As String
sURL = "http://api.hackertarget.com/geoip/?q=1.1.1.1"
我希望能够用用户输入替换 1.1.1.1
谢谢
编辑:
当我运行程序时我需要在控制台中插入两次IP
Dim nL As String = Environment.NewLine
Console.Write("Please enter an IP Address: ")
Dim input = Console.ReadLine()
这是我用来接受用户输入的代码
编辑2: 完整代码
Imports System
Imports System.Net
Imports System.IO
Module Module1
Sub Main()
IP:
Dim nL As String = Environment.NewLine
Console.Write("Please enter an IP Address: ")
'Console.WriteLine()
Dim input = Console.ReadLine()
Dim sURL As String
sURL = "http://api.hackertarget.com/geoip/?q=1.1.1.1".Replace("1.1.1.1", Console.ReadLine())
Dim wrGETURL As WebRequest
wrGETURL = WebRequest.Create(sURL)
Dim myProxy As New WebProxy("myproxy", 80)
myProxy.BypassProxyOnLocal = True
Dim objStream As Stream
objStream = wrGETURL.GetResponse.GetResponseStream()
Dim objReader As New StreamReader(objStream)
Dim sLine As String = ""
Dim i As Integer = 0
Do While Not sLine Is Nothing
i += 1
sLine = objReader.ReadLine
If Not sLine Is Nothing Then
Console.WriteLine("{0}:{1}", i, sLine)
End If
Loop
Console.ReadLine()
GoTo IP
End Sub
模块结束
你应该使用 -
Dim sURL As String
Console.Write("Please enter an IP Address: ")
sURL = "http://api.hackertarget.com/geoip/?q=1.1.1.1".Replace("1.1.1.1", Console.ReadLine())