Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:http/http.dart';
- import 'package:html/dom.dart' show Document;
- import 'package:html/parser.dart' show parse;
- https://vm.tiktok.com/78Dc1Y/?utm_source=copy_link&utm_campaign=client_share&utm_medium=android&share_app_name=musically&share_iid=6817857825445332741
- class Fetch {
- Request rek;
- String mth;
- bool follow;
- Map<String, String> body;
- Map<String, String> header = {
- 'User-Agent':
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36',
- 'Content-Type': 'application/x-www-form-urlencoded'
- };
- Fetch(this.mth, {header, this.body, this.follow: false}) {
- if (header != null) this.header.addAll(header);
- rek = Request(
- mth, Uri.parse('http:/'));
- rek.headers.addAll(this.header);
- //rek.followRedirects = follow;
- }
- Future<StreamedResponse> get sg => rek.send();
- Future<StreamedResponse> get sp => (rek
- //..headers.addAll(header)
- ..bodyFields = body)
- .send();
- Future<StreamedResponse> send() {
- if (mth == 'GET') return sg;
- if (mth == 'POST') return sp;
- throw 'Can\'t create $mth.';
- }
- }
- class DoLogin {
- Map<String, String> pl = {'btEnt': 'Entra'};
- String matricula;
- String senha;
- DoLogin(this.matricula, this.senha);
- login() async {
- print('dologin login');
- pl['txtTexto'] = matricula;
- await Fetch('GET').send().then((response) async {
- await response.stream.bytesToString().then((rHtml) async {
- Document document = parse(rHtml);
- var p = document.getElementsByTagName("[name*='__']");
- for (var i in p) {
- pl[i.attributes['name']] = i.attributes['value'];
- }
- await Fetch('POST', body: pl).send().then((response2) async {
- var cookie = {'Cookie': response2.headers['set-cookie']};
- print(cookie);
- await response2.stream.bytesToString().then((rHtml2) async {
- var document2 = parse(rHtml2);
- pl.clear();
- pl.addAll({'btEnt': 'Entra', 'txtTexto': senha});
- var p2 = document2.getElementsByTagName("[name*='__']");
- for (var i in p2) {
- pl[i.attributes['name']] = i.attributes['value'];
- }
- var d2 = document2.querySelector("#lblMensagem");
- print(d2.text);
- await Fetch('POST', body: pl, header: cookie, follow: true)
- .send()
- .then((response3) async {
- print(response3.statusCode);
- print(response3.headers);
- await response3.stream.bytesToString().then((rHtml3) {
- print(rHtml2);
- var document3 = parse(rHtml3);
- print(document3.body);
- var d3 = document3.querySelector("#lblMensagem");
- if (d3 != null) print(d3.text);
- });
- });
- });
- });
- });
- });
- }
- }
- main() {
- DoLogin('456', '456').login();
- }
- import 'dart:async';
- import 'dart:io';
- import 'package:html/parser.dart' show parse;
- void main() {
- new File('html.txt').readAsString().then((String contents) {
- List lis = [];
- var doc = parse(contents);
- var tab = doc.querySelectorAll('#masterBody_dgPonto tr');
- for(var i in tab) {
- var cada = i.text.split('\n ');
- cada.removeAt(0);
- lis.add(cada);
- }
- lis.removeLast();
- print(lis);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement