【问题标题】:Using Dart to find the content of an H1 tag in an HTML page?使用 Dart 在 HTML 页面中查找 H1 标签的内容?
【发布时间】:2020-05-05 15:39:41
【问题描述】:

所以基本上我正在尝试使用 Dart 和 Flutter 自学移动开发,目前,我正在尝试让移动应用程序连接到网站并获取 H1 标签的文本并暂时将其显示在控制台中.此外,H1 标签正在通过 Javascript 加载。有没有办法做到这一点?

【问题讨论】:

    标签: javascript html dart mobile-application


    【解决方案1】:

    如果我理解正确,这就是你的答案:

    根据 Seth 的评论,您应该可以为此使用 html 库。

    应该是这样的: 导入“包:html/parser.dart”显示解析; 导入'package:html/dom.dart';

    var document = parse(response.body);
    var priceElement = document.getElementsByClassName("product_price_from");
    // priceElement may have weird formatting (I see  ) so you might need to do some parsing
    // here to solve that
    

    更多信息请看here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-04
      • 2015-04-27
      • 2011-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-23
      相关资源
      最近更新 更多