أستخراج نص من موقع ويب - aldery - 06-05-22
السلام عليكم : جزاك الله خيراً أنا اعمل على مشروع ولكن توقفت عند نقطة محددة وهي أستخراج خطوط العرض و الطول من ألايبي لدي هذا الموقع ولكن لم أعرف كيف أستخرج منه النص أتمنى لو أن أحدكم يساعدني بكود لاستخراج خط العرض و الطول من هذا الموقع وشكراً لكم
رابط الموقع المطلوب :https://ipaddress.my/111.22.24.44
واذا كان هناك موقع اخر لا مشكلة فقط اريد كود يستخرج خط العرض و الطول
RE: أستخراج نص من موقع ويب - trakktour - 06-05-22
(06-05-22, 12:18 AM)aldery كتب : السلام عليكم : جزاك الله خيراً أنا اعمل على مشروع ولكن توقفت عند نقطة محددة وهي أستخراج خطوط العرض و الطول من ألايبي لدي هذا الموقع ولكن لم أعرف كيف أستخرج منه النص أتمنى لو أن أحدكم يساعدني بكود لاستخراج خط العرض و الطول من هذا الموقع وشكراً لكم
رابط الموقع المطلوب :https://ipaddress.my/111.22.24.44
واذا كان هناك موقع اخر لا مشكلة فقط اريد كود يستخرج خط العرض و الطول
و عليكم السلام
تفضل
كود :
Try : Net.ServicePointManager.CheckCertificateRevocationList = False : Net.ServicePointManager.DefaultConnectionLimit = 300 : Net.ServicePointManager.UseNagleAlgorithm = False : Net.ServicePointManager.Expect100Continue = False : Net.ServicePointManager.SecurityProtocol = 3072
Dim Encoding As New System.Text.UTF8Encoding
Dim AJ As Net.HttpWebRequest = DirectCast(Net.WebRequest.Create("https://ipaddress.my/111.22.24.44"), Net.HttpWebRequest)
With AJ
.Method = "GET"
.Proxy = Nothing
.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
End With
Dim Response As Net.HttpWebResponse = DirectCast(AJ.GetResponse, Net.HttpWebResponse)
Dim reader As New IO.StreamReader(Response.GetResponseStream) : Dim text As String = reader.ReadToEnd : reader.Dispose() : reader.Close() : Response.Dispose() : Response.Close()
Dim Latitude As String = System.Text.RegularExpressions.Regex.Match(text, "<td>Latitude:<\/td>\s<td>(.*?)<\/td>").Groups(1).Value
Dim Longitude As String = System.Text.RegularExpressions.Regex.Match(text, "<td>Longitude:<\/td>\s<td>(.*?)<\/td>").Groups(1).Value
MsgBox(Longitude)
Catch ex As System.Net.WebException : Dim AJJ As String = New IO.StreamReader(ex.Response.GetResponseStream()).ReadToEnd() : MsgBox("Error : " & AJJ) : End Try
RE: أستخراج نص من موقع ويب - aldery - 06-05-22
(06-05-22, 02:13 AM)trakktour كتب : (06-05-22, 12:18 AM)aldery كتب : السلام عليكم : جزاك الله خيراً أنا اعمل على مشروع ولكن توقفت عند نقطة محددة وهي أستخراج خطوط العرض و الطول من ألايبي لدي هذا الموقع ولكن لم أعرف كيف أستخرج منه النص أتمنى لو أن أحدكم يساعدني بكود لاستخراج خط العرض و الطول من هذا الموقع وشكراً لكم
رابط الموقع المطلوب :https://ipaddress.my/111.22.24.44
واذا كان هناك موقع اخر لا مشكلة فقط اريد كود يستخرج خط العرض و الطول
و عليكم السلام
تفضل
كود :
Try : Net.ServicePointManager.CheckCertificateRevocationList = False : Net.ServicePointManager.DefaultConnectionLimit = 300 : Net.ServicePointManager.UseNagleAlgorithm = False : Net.ServicePointManager.Expect100Continue = False : Net.ServicePointManager.SecurityProtocol = 3072
Dim Encoding As New System.Text.UTF8Encoding
Dim AJ As Net.HttpWebRequest = DirectCast(Net.WebRequest.Create("https://ipaddress.my/111.22.24.44"), Net.HttpWebRequest)
With AJ
.Method = "GET"
.Proxy = Nothing
.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
End With
Dim Response As Net.HttpWebResponse = DirectCast(AJ.GetResponse, Net.HttpWebResponse)
Dim reader As New IO.StreamReader(Response.GetResponseStream) : Dim text As String = reader.ReadToEnd : reader.Dispose() : reader.Close() : Response.Dispose() : Response.Close()
Dim Latitude As String = System.Text.RegularExpressions.Regex.Match(text, "<td>Latitude:<\/td>\s<td>(.*?)<\/td>").Groups(1).Value
Dim Longitude As String = System.Text.RegularExpressions.Regex.Match(text, "<td>Longitude:<\/td>\s<td>(.*?)<\/td>").Groups(1).Value
MsgBox(Longitude)
Catch ex As System.Net.WebException : Dim AJJ As String = New IO.StreamReader(ex.Response.GetResponseStream()).ReadToEnd() : MsgBox("Error : " & AJJ) : End Try
مشكور أخي الكريم جزاك الله خيراً
|