小编Gui*_*mao的帖子

Flutter http response.body 错误的 utf8 编码

我开始学习 Flutter,并通过制作自己的manga阅读应用程序来实现这一目标,在该应用程序中,我从我最常使用的网站上抓取所有数据。

\n\n

我的问题是,由于此错误,只有我读到的其中一篇mangas无法抓取数据:

\n\n
FormatException (FormatException: Bad UTF-8 encoding 0x22 (at offset 369))\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的爬虫代码

\n\n
    Future<Manga> getMangaInfo(source) async{\n    final response =  await _client.get(source);\n    var manga;\n    print(response.body);//error occurs here\n    final document = parse(response.body);\n\n    final mangaInfo = document.getElementsByClassName(\'tamanho-bloco-perfil\');\n    for(Element infos in mangaInfo){\n      final infoCont = infos.getElementsByClassName(\'row\');\n      //get titulo\n      Element tituloCont = infoCont[0];\n      final tituloH = tituloCont.getElementsByTagName(\'h2\');\n      Element tituloCont2 = tituloH[0];\n      String titulo = \'[\'+tituloCont2.text+\']\';\n      //print(titulo);\n\n      //get capa\n\n      Element capaCont = infoCont[2];\n      final capaImg = capaCont.getElementsByTagName(\'img\');\n …
Run Code Online (Sandbox Code Playgroud)

html http utf-8 flutter

15
推荐指数
2
解决办法
2万
查看次数

标签 统计

flutter ×1

html ×1

http ×1

utf-8 ×1