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

首頁 > 編程 > HTML > 正文

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

2024-08-26 00:15:37
字體:
來源:轉載
供稿:網友

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;
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 河津市| 乌鲁木齐县| 偃师市| 德钦县| 康马县| 滦南县| 吴川市| 双桥区| 莆田市| 大渡口区| 日土县| 正宁县| 营口市| 娱乐| 台湾省| 巴彦淖尔市| 黄冈市| 洛宁县| 合水县| 盘锦市| 柘城县| 绥中县| 台州市| 乐昌市| 调兵山市| 沁阳市| 吉安市| 珠海市| 兴山县| 石棉县| 黔南| 青铜峡市| 南投市| 漳州市| 兴海县| 绥德县| 泾源县| 托里县| 云林县| 拜城县| 南宁市|