怎么用程序获取远程url执行后的图片地址
2016-06-16 22:30
351 查看
远程URL:https://121.199.16.229:8890/generate.cgi?rbid=1001&esn=22021434025005&pic=png&count=1&pix=250&cor=lo&comm=%E6%B5%A6%E6%B1%9F%E6%B8%B8%E8%A7%881%E5%8F%B7%E9%BE%99%E8%88%B9%2F%E5%B7%A5%E8%A1%8C%E5%8F%B7%EF%BC%8C2013%E5%B9%B46%E6%9C%881%E5%8F%B7%EF%BD%9E2013%E5%B9%B46%E6%9C%8831%E5%8F%B7%EF%BC%8C14%3A00
执行后:会生成一个图片地址 如https://121.199.16.229:8890/cgi/1001313097265699.png
怎么用程序 通过 内部访问 远程URL 获得这个 图片的URL
回答:
HttpWebRequest设置AutoRedirection就可以了。它会自动处理301跳转。
添加System.Net和System.Security两个dll,引入相应命名空间。
执行后:会生成一个图片地址 如https://121.199.16.229:8890/cgi/1001313097265699.png
怎么用程序 通过 内部访问 远程URL 获得这个 图片的URL
回答:
HttpWebRequest设置AutoRedirection就可以了。它会自动处理301跳转。
添加System.Net和System.Security两个dll,引入相应命名空间。
static void Main(string[] args) { HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("https://121.199.16.229:8890/generate.cgi?rbid=1001&esn=22021434025005&pic=png&count=1&pix=250&cor=lo&comm=%E6%B5%A6%E6%B1%9F%E6%B8%B8%E8%A7%881%E5%8F%B7%E9%BE%99%E8%88%B9%2F%E5%B7%A5%E8%A1%8C%E5%8F%B7%EF%BC%8C2013%E5%B9%B46%E6%9C%881%E5%8F%B7%EF%BD%9E2013%E5%B9%B46%E6%9C%8831%E5%8F%B7%EF%BC%8C14%3A00"); ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);//验证服务器证书回调自动验证 WebResponse webResponse = webRequest.GetResponse(); Console.WriteLine(webResponse.ResponseUri.AbsoluteUri);//输出https://121.199.16.229:8890/cgi/1001363993292848.png } public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { // 总是接受 return true; }
相关文章推荐
- shell脚本中反引号与$()的区别
- python ssh
- ffmpeg 从视频流中抓取图片
- lamp centos虚拟主机配置
- 如何查找Mac上的USB存储设备使用痕迹
- scala学习手记13 - 类继承
- SQL服务器无法登陆SQL控制台
- 168. Excel Sheet Column Title
- 豆瓣最受欢迎的影评爬虫(第一个爬虫撒花!)
- 数组去重
- 【C】文件读写操作
- python 查询 MongoDB 数据库pymongo.errors.OperationFailure: cursor id '26777532088498352' not valid at se
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- SQL注入原理讲解
- Educational Codeforces Round 13
- 每天一道ACM(四)
- centos linux中怎么查看和修改计算机名/etc/sysconfig/network
- 【一天一道LeetCode】#94. Binary Tree Inorder Traversal
- php mysql_insert_id()