منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : جلب الرابط بعد التحويل؟ | httpwebrequest | get url after redirect
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
httpwebrequest get url after redirect

السلام عليكم

ازاى اظهر الرابط بعد التحويل؟

مثلا https://goo.gl/b3k9Bn

عند انتهاء تحميل الطلب

سوف يكون الرابط

https://www.instagram.com/accounts/signu...cess_token=...................

ازاى اظهره فى رسالة ؟

عبر الاتصال ب httpwebrequest

جربت
كود :
Dim uurl As String = "https://goo.gl/b3k9Bn"
        Dim request As HttpWebRequest = DirectCast(HttpWebRequest.Create(uurl), HttpWebRequest)
        request.Method = "GET"
        request.KeepAlive = True
        request.CookieContainer = mycontainer2
        request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/49.0"
        request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
        request.ContentType = "application/x-www-form-urlencoded"
        Dim response As HttpWebResponse = Nothing
        response = DirectCast(request.GetResponse(), HttpWebResponse)
        Dim str2 As String = New StreamReader(response.ResponseUri.AbsoluteUri).ReadToEnd

ولكن يظهر خطأ 404 فى هذا السطر

response = DirectCast(request.GetResponse(), HttpWebResponse)

ياترى فى حل؟؟
خذ الرابط من response

خذ الرابط من response
PHP كود :
Dim url As String response.ResponseUri.ToString 
(17-11-16, 05:00 AM)السرور كتب : [ -> ]خذ الرابط من  response

خذ الرابط من  response
PHP كود :
Dim url As String response.ResponseUri.ToString 

المشكلة ان الويب ريكسوت بيعطى الاستجابة فيها خطأ 404

بمعنى ان الصفحة غير موجودة وكدا مش بيكمل الاستجابة اصلا

وهى دى المشكلة
وانا مش عايزه يكمل الاستجابة انا عايز فقط اخد الرابط عندما يصل للخطأ 404 هذا
انا اقصد قبل السطر اللي بتقول عليه
يعني جرب هذا الكود
PHP كود :
Dim uurl As String "https://goo.gl/b3k9Bn"
 
       Dim request As HttpWebRequest HttpWebRequest.Create(uurl)
 
       request.Method "GET"
 
       request.KeepAlive True
        request
.CookieContainer mycontainer2
        request
.UserAgent "Mozilla/5.0"
 
       request.Accept "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
 
       request.ContentType "application/x-www-form-urlencoded"
 
       Dim response As HttpWebResponse request.GetResponse()
 
       Dim url As String response.ResponseUri.ToString 

انا جربته وما يعطيني هذا الخطأ 404
(17-11-16, 07:50 AM)السرور كتب : [ -> ]انا اقصد قبل السطر اللي بتقول عليه
يعني جرب هذا الكود
PHP كود :
Dim uurl As String "https://goo.gl/b3k9Bn"
 
       Dim request As HttpWebRequest HttpWebRequest.Create(uurl)
 
       request.Method "GET"
 
       request.KeepAlive True
        request
.CookieContainer mycontainer2
        request
.UserAgent "Mozilla/5.0"
 
       request.Accept "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
 
       request.ContentType "application/x-www-form-urlencoded"
 
       Dim response As HttpWebResponse request.GetResponse()
 
       Dim url As String response.ResponseUri.ToString 

انا جربته وما يعطيني هذا الخطأ 404


هو لا يعطيك خطأ لان قيمة الكوكاييز عندك فارغة ويجب ان تكون فيها كوكاييز حسابك الفيس بوك بعد تسجيل الدخول له

الحمدلله وصلت لحل

request.Address.AbsoluteUri.ToString

شكرا اخى لتعبك معى