如何在请求后以字符串形式获取重定向的网址
例如,在任何tinyurl/ajdeijad链接(这个是假的)上,think重定向到另一个url
这是我的代码:
Dim request1 As HttpWebRequest = DirectCast(HttpWebRequest.Create(urlvimeohd), HttpWebRequest)
request1.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"
request1.MaximumAutomaticRedirections = 1
request1.AllowAutoRedirect = True
如何检索响应的url(它重定向!)
For example on any tinyurl/ajdeijad link (this one is fake), the think redirects to another url
Here is my code:
Dim request1 As HttpWebRequest = DirectCast(HttpWebRequest.Create(urlvimeohd), HttpWebRequest)
request1.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"
request1.MaximumAutomaticRedirections = 1
request1.AllowAutoRedirect = True
How do you retrieve the url of the response (it redirects!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简单 - 只需获取响应的 reponseuri 即可!
http://msdn.microsoft.com/en-us /library/system.net.webresponse.responseuri.aspx
Simple - just get the reponseuri of the response!
http://msdn.microsoft.com/en-us/library/system.net.webresponse.responseuri.aspx
我知道找到它重定向到的 URL 的唯一方法是发出请求并读取响应。
仅供参考:您应该查看 Fiddler。它是一个免费的应用程序,可让您直观地检查浏览器发出的请求和响应。您可以将该链接复制粘贴到浏览器中,然后查看服务器返回的内容。然后你就会知道要检查哪个标题来获取你想要的信息。
希望有帮助。
The only way I know of to find which URL it redirects to is by making the request and reading the response.
FYI: You should check out Fiddler. It's a free app that will allow you to visually inspect the requests and responses made by your browser. You can copy paste that link you have into your browser and see what the server says back. Then you'll know which Header to check for the info you want.
Hope that helps.
试试这个,
这将返回重定向的 URL。
Try This,
This will return the redirected URL.