0

Well i'm a student , and i'm still learning the dart language and the flutter framework, I was trying to make an application that makes you able to login into a site with a http post request and get data by manipulating the response of the html source code with some regular expressions to get what you need from the website, (something like data scraping)

I tried to do that but nothing worked as planned.

I did this project! years ago and it was for desktop, with vb.net, I used a library called xNet which helped me to do that.

For this case I used the http dart package.

Is this kind of work can be done with dart?
Is there any specific packages for this?
Is there any docs available ?

I know html is not a regular language, i asked if it is possible to use http requests to login into a site!? if i can do that i can manipulate the response and get what i need with some regular expressions.

I wanna do something like C#

using (HttpRequest req = new HttpRequest())
{
    req.UserAgent = Http.ChromeUserAgent;
    req.Cookies = new CookieDictionary(false);
    req.Proxy = null;
    req.IgnoreProtocolErrors = true;

    req.AddParam("login", cin.Text);
    req.AddParam("no_anti_inject_password", pass.Text);

    try {
            string Respo = req.Post("http://www.example.com/login.php").ToString;

            // to with that 'Respo'
            if (Respo.Contains("disconnect"))
            {
                    //Logged
                    //example
                    Match NAME = Regex.Match(Respo, "<a href=\"\" class=\"strong\">(.*?)</a>");
                    name.Text = "Name: " + NAME.Groups(1).Value;

            }else{
                    //not logged
                    //some code...
            }
    catch{
            //some exception
    }

}
Khalil Mejdi
  • 132
  • 1
  • 8

1 Answers1

2

HTML is not a regular language and so a regular expression is not a good way to scrape data from html. You may be interested in package:html which implements an HTML parser.

Nate Bosch
  • 10,145
  • 2
  • 26
  • 22
  • I am fully aware that HTML is not a regex language but i can scrap data from it with regex and that's what I am looking for – Khalil Mejdi Jul 24 '19 at 13:36