zoukankan      html  css  js  c++  java
  • 下载url地址的图片

    // string url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=cNaaMfvhpb1vmcVRXRAdIjRX3eUFsk1sRVrbOaPkR-8Gbli4xJE22sI9uLaf3q_aCIesyUtZ7KC4WvOKN9XquxWCHviW5yqMDJxojm-MMHE&media_id=wcrGxYBc_CotfNILfPtIPZNZS8N4GGhSpAP561qKY1s2AWYZXgPAD6dekWgCrHjK";

    string url = "http://mmbiz.qpic.cn/mmbiz/PwIlO51l7wuFyoFwAXfqPNETWCibjNACIt6ydN7vw8LeIwT7IjyG3eeribmK4rhibecvNKiaT2qeJRIWXLuKYPiaqtQ/0";
    string path = @"D:5555555555555555555555555.jpg";
    // string file = string.Empty;
    string content = string.Empty;
    string strpath = string.Empty;
    string savepath = string.Empty;


    HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);

    req.Method = "GET";
    using (WebResponse wr = req.GetResponse())
    {
    HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse();
    strpath = myResponse.ResponseUri.ToString();
    WebClient mywebclient = new WebClient();
    savepath = Server.MapPath("Images") + "\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next().ToString().Substring(0, 4) + ".jpg";
    try
    {
    mywebclient.DownloadFile(strpath, savepath);
    // file = savepath;
    }
    catch (Exception ex)
    {
    savepath = ex.ToString();
    }

    }
    // return file;

    // WebClient WebClient = new WebClient();

    //myWebClient.DownloadFile(myStringWebResource,fileName);
    // WebClient.DownloadFile(address, "D::\deeeeeeeeeeeeedd.png");
    // Fcity.Core.FileSources.ChangeImageSize("D:\QQ截图20141205121451.png", "D:\ddd.png", 1000, 1000, ImageFormat.Jpeg);

    return;

  • 相关阅读:
    Remote API(RAPI)之 文件管理
    vue前端框架

    托马斯彩色回旋
    VUE?
    cookie与session
    ajax前后端分离
    djangoIII
    Django少年
    django三板斧
  • 原文地址:https://www.cnblogs.com/lyl6796910/p/4343742.html
Copyright © 2011-2022 走看看