我目前正在制作一个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()
这是我用来获取用户输入的代码
EDIT2: 完整代码
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
结束模块
答案 0 :(得分:0)
你应该使用 -
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())