Right now I have a foreach loop that grabs the first link with an img tag.
I want to be able to edit this link I get and then put it in a request.
For example say I get back “http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif” and I only want to keep the “p-c1rF4kxgLUzNc” part and then put that into a new url in a httprequest.
The link would be random so I can’t simply just put a static url, I want the one the list gets.
List<string> imgtags = new List<string>();
foreach(HtmlNode link in doc.DocumentNode.SelectNodes("//img[@src]"))
{
HtmlAttribute att = link.Attributes["src"];
imgtags.Add(att.Value);
break;
}
//edit the url the list gets
HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create("http://google.com/" + *editedurl*);
This probably isnt the best way of doing it, but you could do a split on the original link, something like this:
Then you could work out which the last element of the link array is and do a split on that as well. I am using 7 as an example here.
Then you would just need to use newLink[0] and you would have the name that you wanted.
As i say this isnt a pretty way of doing it, but its a workaround if you dont get any better answers.