Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

code scrapping in c#

$
0
0

Hi, is there any way i could like crap one part of the HTML code from the page and then send it back to do some thing for me.

Example:

I'd like to make an app that every time i run it automaticly logs me in into my Gmail account.

I've got some code here but it says:

-Error    2    The name 'url' does not exist in the current context    C:\Users\user\Desktop\HTML\HTML\Program.cs    31    40    HTML
-Error    1    A local variable named 'args' cannot be declared in this scope because it would give a different meaning to 'args', which is already used in a 'parent or current' scope to denote something else    C:\Users\user\Desktop\HTML\HTML\Program.cs   18    51    HTML

Thank you.

     namespace HTML
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new WebClient();
            client.DownloadStringCompleted += (s, args) =>
            {
                if (args.Error == null && !args.Cancelled)
                {
                    var regex = new Regex("<title>(?<title>.*?)</title>");
                    var match = regex.Match(args.Result);
                    if (match.Success)
                    {
                        var myTitle = match.Groups["title"].Value;
                        // ...
                    }
                }
            };
            client.DownloadStringAsync(url);
        }
    }
}


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>