如何在卷纸中使用分页刮纸

时间:2020-08-15 07:36:39

标签: html flutter web dart screen-scraping

我要使用此代码进行网页抓取并在页面抖动中进行分页

此网址网址https://manga.ae/manga/

这是功能代码

      Future<List<TeamModel>> getpageAll() async {
        List<TeamModel> pagelist = [];


    var response = await _client.get(url);
    final document = parse(response.body);

    final result = document.querySelectorAll('[class=pagination]');
    for (dom.Element resu in result) {
      final res1 = resu.getElementsByTagName('a');
      for (dom.Element res in res1) {
        final href = res.attributes['href'];
        int mpage = href.length;
        for (int i = 0; i < mpage; i++) {
          final dddfgd = document.getElementsByClassName('mangacontainer').sublist(i);

          for (dom.Element ddd2u in dddfgd) {
            final last = ddd2u.querySelectorAll('[class=details] > a').sublist(i);
            for (dom.Element last in last) {
              final lastnub = last.text;
              // final numblast = lastnub.text;
              final firstclass = ddd2u.getElementsByTagName('a')[0];
              final href = firstclass.attributes['href'];

              final hrefdetail = ddd2u.text;
              final imagee = ddd2u.getElementsByTagName('img').sublist(i);
              for (dom.Element iiif in imagee) {
                final name = iiif.attributes['alt'];

                final imag = iiif.attributes['src'];
                print(imag);
                print(name);
                print(href);
                print(hrefdetail);
                print(lastnub);

                final all = TeamModel(
                  name: name,
                  image: imag,
                  href: href,
                  herfdeatil: hrefdetail,
                  numblast: lastnub,
                );
                // imagenew: imagnew);
                pagelist.add(all);
                // }
                // }
              }
            }
          }
        }
      }
    }
    return pagelist;
  }

0 个答案:

没有答案