Click here to Skip to main content
15,915,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to start a personal link exchange program where a person can place my link on their site and I will place their link on mine . I would like to know how to detect the link on a website if they specify the page where the link is going to be placed Thanks in advance.
Posted

Probably the quickest way would be to parse the HTML from the URL they provide, and then run a string.Contains(string) against it to check for the existence of whatever you expect to see there.
eg

string link = "http://example.com/example";
string url = "http://otherperson.com/page/where/your/link/is";
string pageContents = getPageContents(url);
bool isThere = pageContents.Contains(link);
public string getPageContents(string url) {
	HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
	using (Stream stream = request.GetResponse().GetResponseStream()) {
		using (StreamReader reader = new StreamReader(stream)) {
			string response = reader.ReadToEnd();
			return response;
		}
	}
}


** This will not confirm that the link is visible or viable, as having the URL in a commented out section will still return a positive.
 
Share this answer
 
Comments
Member 7790032 7-Apr-11 17:40pm    
I guess there is no definite way to assure the link is visible. Thanks for the prompt response
Member 7790032 7-Apr-11 17:47pm    
I guess if i can find it then crawler can find the link
Albin Abel 8-Apr-11 2:19am    
My 5
If I understand your question, you want to identify who referred a visitor to your site. You can use either the referring URL or you can even give your link-companions unique IDs which they can pass to you through a parameter. Example: somedomain/somepage.aspx?refid=9065 (where 9065 identifies who the link's coming from).
 
Share this answer
 
v2
Comments
Albin Abel 8-Apr-11 2:19am    
Good idea. My 5
ctwi001's answer is good one to retrieve the website content. But there is a simple way too.

Alternatively can use webclient class. WebClient wc=new WebClicnt(); string content=wc.DownloadString(urlPath);. Cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900