2020年12月23日星期三

How to submit a form html with Dart?

I need to scrap some data for the Dart / Flutter application and I need to log in to access the page.

How do I submit changes to the form data and click on the login button? I tried as follows:

    var loginPage = await http.get('https://mypage.com/login');      var document = parse(loginPage.body);      var username = document.querySelector('#username') as InputElement;      var password = document.querySelector('#password') as InputElement;      username.value = 'USERNAME';      password.value = 'PASSWORD';      var submit = document.querySelector('.btn-submit') as ButtonElement;      submit.click();  

But I have the following error:

Error: 'InputElement' isn't a type.  Error: 'ButtonElement' isn't a type.  

I also tried the following:

InputElement username = document.querySelector('#username');  

But a get the error A value of type 'Element' can't be assigned to a variable of type 'InputElement'

I need to make this scrap in the flutter application to avoid passing the password using API.

How can I log in to the page to get the data?

https://stackoverflow.com/questions/65432998/how-to-submit-a-form-html-with-dart December 24, 2020 at 09:41AM

没有评论:

发表评论