-3

I want to write a code in C#

  1. Go to www.abc.com > read the whole text available on the page > save the text to string1 then
  2. Go to www.xyz.com > read the whole text available on the page > save the text to string2 then
  3. Compare string1 with string2 to verify they are same

eg.

if string1 = "Hello World" and string2 = "Hello World" > test passes

if string1 = "Hello World" and string2 = "Hello Tom" > test fails

xRay
  • 11
  • 5
  • Great. Open up a compiler and start coding. If you encounter problems, feel free to ask for help here. If you need someone to code this for you, look at a site that rents coders. – nvoigt Jul 11 '14 at 05:43
  • "read the whole text available on the page" means the complete HTML page or it should only compare the content in the body and ignore HTML tags? – jpgauthier Jul 11 '14 at 05:46
  • read the whole text available on the page including tags, thanks – xRay Jul 11 '14 at 05:48
  • 2
    This question appears to be off-topic because it is a blatant request for code with no demonstrated attempt at solving the problem at hand. – g.d.d.c Jul 11 '14 at 06:01
  • start off by learning how to download a web page in c# - http://stackoverflow.com/questions/4510212/how-i-can-get-web-pages-content-and-save-it-into-the-string-variable – Unglued Jul 11 '14 at 06:12

1 Answers1

3

It's always nice to post code snippets, so it proves us that you actually tried something. But there you go, it's a pretty simple task...

public class TestClass
{
    public static void Main(string[] args)
    {
        bool isEqual = DownloadString("www.abc.com") == DownloadString("www.xyz.com")
        // do whatever you want with it
    }    

    private static string DownloadString(string address)
    {
        using (WebClient client = new WebClient())
        {
            return client.DownloadString(address);
        }
    }
}
jpgauthier
  • 256
  • 1
  • 3