I want to extract the image from server and store it in my local system. The image is displayed as background in <img> tag. How to extract and store the image. The actual image tag is given below
<img style="background:Url('..//contactdetails?data=4512354367432554')" src="some transparent image"/>
In the above tag image is being displayed as background and src contains some transparent image.
You need to perform a request for the image and then save it on your machine.
First get the URI of the image:
EDIT
If you are using
HtmlAgilityPack(given that you already extracted theatag) you can use theAttributescollection to get thestyleattribute and perform a match against the regular expression or you can use directly theOuterHtmlproperty to match against the pattern like this:Or, using the
OuterHtmlproperty:Next, concatenate the uri of the image to the directory from server, and create a request:
Get the response and save the image: