Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 从服务器获取映像的完整路径_Html_C# 4.0_Html Parsing - Fatal编程技术网

Html 从服务器获取映像的完整路径

Html 从服务器获取映像的完整路径,html,c#-4.0,html-parsing,Html,C# 4.0,Html Parsing,我想从服务器中提取图像并将其存储在本地系统中。图像在 在上面的标签中,图像显示为背景,src包含一些透明图像。您需要对图像执行请求,然后将其保存在计算机上。 首先获取图像的URI: <img style="background:Url('..//contactdetails?data=4512354367432554')" src="some transparent image"/> var fullUri = "http://www.example.com/" + uri; v

我想从服务器中提取图像并将其存储在本地系统中。图像在


在上面的标签中,图像显示为背景,src包含一些透明图像。

您需要对图像执行请求,然后将其保存在计算机上。 首先获取图像的URI:

<img style="background:Url('..//contactdetails?data=4512354367432554')" src="some transparent image"/>
var fullUri = "http://www.example.com/" + uri;
var request = (HttpWebRequest)WebRequest.Create(fullUri);
或者,使用
OuterHtml
属性:

var anchorTag = YourCodeToGetTheAnchorTag();
var attribute = anchorTag.Attributes["style"];
var match = regex.Match(attribute.Value);
var uri = match.Groups["Path"].Value;
接下来,将映像的uri连接到来自服务器的目录,并创建一个请求:

var anchorTag = YourCodeToGetTheAnchorTag();
var match = regex.Match(anchorTag.OuterHtml);
var uri = match.Groups["Path"].Value
获取响应并保存图像:

<img style="background:Url('..//contactdetails?data=4512354367432554')" src="some transparent image"/>
var fullUri = "http://www.example.com/" + uri;
var request = (HttpWebRequest)WebRequest.Create(fullUri);

谢谢你,雷皮尔,我正在使用htmlagilitypack进行提取。你能用c语言演示一下怎么做吗。我试图修改你的代码并使用它,但它不起作用。