国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

如何把html中的相對路徑變成絕對路徑

2019-11-18 17:10:51
字體:
供稿:網(wǎng)友

PRivate static string ConvertToAbsoluteUrls (string html, Uri relativeLocation) {
    IHTMLDocument2 doc = new HTMLDocumentClass ();
    doc.write (new object [] { html });
    doc.close ();

    foreach (IHTMLAnchorElement anchor in doc.links) {
        IHTMLElement element = (IHTMLElement)anchor;
        string href = (string)element.getAttribute ("href", 2);
        if (href != null) {
            Uri addr = new Uri (relativeLocation, href);
            anchor.href = addr.AbsoluteUri;
        }
    }

    foreach (IHTMLImgElement image in doc.images) {
        IHTMLElement element = (IHTMLElement)image;
        string src = (string)element.getAttribute ("src", 2);
        if (src != null) {
            Uri addr = new Uri (relativeLocation, src);
            image.src = addr.AbsoluteUri;
        }
    }

    string ret = doc.body.innerHTML;

    return ret;
}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 松桃| 达州市| 岳阳市| 鲁甸县| 兴安盟| 吐鲁番市| 习水县| 清远市| 吉安县| 临夏市| 衡阳市| 烟台市| 罗城| 诸暨市| 上高县| 河源市| 扎囊县| 林口县| 荣昌县| 景洪市| 叙永县| 临沭县| 平邑县| 辛集市| 石棉县| 曲沃县| 会理县| 林西县| 陇南市| 淅川县| 嵊州市| 广水市| 军事| 泰安市| 天气| 桦甸市| 克山县| 巢湖市| 隆德县| 崇义县| 雷山县|