【发布时间】:2011-08-08 23:00:45
【问题描述】:
我正在屏幕抓取网页并将其作为 html 电子邮件发送。
操纵 html 为所有图像和 css 文件设置完整 http 地址的最简单/最佳方法是什么?
当前方法类似于(手动输入)+这很容易出错。
string html = rawHtml.replace("=\"", "=\"" + Request["SERVER_NAME"]);
.
.
这是我们使用 GET 进行屏幕抓取的当前函数
public static string WebGet(string address)
{
string result = "";
using (WebClient client = new WebClient())
{
using (StreamReader reader = new StreamReader(client.OpenRead(address)))
{
string s = reader.ReadToEnd();
result = s;
}
}
return result;
}
【问题讨论】:
-
所以您想将相对 URL 解析为绝对 URL,即
img src="/images/img.jpg"变为img src="http://example.com/images/img.jpg,CSS(和链接)类似?
标签: asp.net asp.net-mvc screen-scraping