Flutter, fetching specfic image from website

Multi tool use
Multi tool use












2















I'm learning flutter and want to fetch various images which are the thumbnail of the cartoon. I used HTTP library and fetched response data.



But, how can I extract that image?



Website: https://comic.naver.com/webtoon/weekdayList.nhn?week=



cartoon image



Future<http.Response> _getData() async {
return await http.get('https://comic.naver.com/webtoon/weekdayList.nhn?week=');
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
),
body: Center(
child: RaisedButton(
child: Text("Fetching"),
onPressed: (){
_getData().then((response){
//dom.Document document = parser.parse(response.body);
print(response.body);
}).catchError((e) => print(e));
},
),
),
);
}





What I want to do is below.




  1. Fetching web page as HTML code

  2. Find image url of each cartoon

  3. Fetch that image











share|improve this question

























  • Why are you not using docs.flutter.io/flutter/painting/NetworkImage-class.html ?

    – Günter Zöchbauer
    Dec 31 '18 at 7:00











  • @GünterZöchbauer Maybe because he is new to this and doesn't know about it?

    – zuckerburg
    Dec 31 '18 at 7:01











  • To use that library, I have to know the url of image and it leads to that have to extract that url in web page.

    – baeharam
    Dec 31 '18 at 7:01











  • So you want to extract the URL, not the image.

    – Günter Zöchbauer
    Dec 31 '18 at 7:02











  • Yes, I edited plz see

    – baeharam
    Dec 31 '18 at 7:03
















2















I'm learning flutter and want to fetch various images which are the thumbnail of the cartoon. I used HTTP library and fetched response data.



But, how can I extract that image?



Website: https://comic.naver.com/webtoon/weekdayList.nhn?week=



cartoon image



Future<http.Response> _getData() async {
return await http.get('https://comic.naver.com/webtoon/weekdayList.nhn?week=');
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
),
body: Center(
child: RaisedButton(
child: Text("Fetching"),
onPressed: (){
_getData().then((response){
//dom.Document document = parser.parse(response.body);
print(response.body);
}).catchError((e) => print(e));
},
),
),
);
}





What I want to do is below.




  1. Fetching web page as HTML code

  2. Find image url of each cartoon

  3. Fetch that image











share|improve this question

























  • Why are you not using docs.flutter.io/flutter/painting/NetworkImage-class.html ?

    – Günter Zöchbauer
    Dec 31 '18 at 7:00











  • @GünterZöchbauer Maybe because he is new to this and doesn't know about it?

    – zuckerburg
    Dec 31 '18 at 7:01











  • To use that library, I have to know the url of image and it leads to that have to extract that url in web page.

    – baeharam
    Dec 31 '18 at 7:01











  • So you want to extract the URL, not the image.

    – Günter Zöchbauer
    Dec 31 '18 at 7:02











  • Yes, I edited plz see

    – baeharam
    Dec 31 '18 at 7:03














2












2








2








I'm learning flutter and want to fetch various images which are the thumbnail of the cartoon. I used HTTP library and fetched response data.



But, how can I extract that image?



Website: https://comic.naver.com/webtoon/weekdayList.nhn?week=



cartoon image



Future<http.Response> _getData() async {
return await http.get('https://comic.naver.com/webtoon/weekdayList.nhn?week=');
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
),
body: Center(
child: RaisedButton(
child: Text("Fetching"),
onPressed: (){
_getData().then((response){
//dom.Document document = parser.parse(response.body);
print(response.body);
}).catchError((e) => print(e));
},
),
),
);
}





What I want to do is below.




  1. Fetching web page as HTML code

  2. Find image url of each cartoon

  3. Fetch that image











share|improve this question
















I'm learning flutter and want to fetch various images which are the thumbnail of the cartoon. I used HTTP library and fetched response data.



But, how can I extract that image?



Website: https://comic.naver.com/webtoon/weekdayList.nhn?week=



cartoon image



Future<http.Response> _getData() async {
return await http.get('https://comic.naver.com/webtoon/weekdayList.nhn?week=');
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
),
body: Center(
child: RaisedButton(
child: Text("Fetching"),
onPressed: (){
_getData().then((response){
//dom.Document document = parser.parse(response.body);
print(response.body);
}).catchError((e) => print(e));
},
),
),
);
}





What I want to do is below.




  1. Fetching web page as HTML code

  2. Find image url of each cartoon

  3. Fetch that image








html http flutter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 31 '18 at 7:03







baeharam

















asked Dec 31 '18 at 6:44









baeharambaeharam

498




498













  • Why are you not using docs.flutter.io/flutter/painting/NetworkImage-class.html ?

    – Günter Zöchbauer
    Dec 31 '18 at 7:00











  • @GünterZöchbauer Maybe because he is new to this and doesn't know about it?

    – zuckerburg
    Dec 31 '18 at 7:01











  • To use that library, I have to know the url of image and it leads to that have to extract that url in web page.

    – baeharam
    Dec 31 '18 at 7:01











  • So you want to extract the URL, not the image.

    – Günter Zöchbauer
    Dec 31 '18 at 7:02











  • Yes, I edited plz see

    – baeharam
    Dec 31 '18 at 7:03



















  • Why are you not using docs.flutter.io/flutter/painting/NetworkImage-class.html ?

    – Günter Zöchbauer
    Dec 31 '18 at 7:00











  • @GünterZöchbauer Maybe because he is new to this and doesn't know about it?

    – zuckerburg
    Dec 31 '18 at 7:01











  • To use that library, I have to know the url of image and it leads to that have to extract that url in web page.

    – baeharam
    Dec 31 '18 at 7:01











  • So you want to extract the URL, not the image.

    – Günter Zöchbauer
    Dec 31 '18 at 7:02











  • Yes, I edited plz see

    – baeharam
    Dec 31 '18 at 7:03

















Why are you not using docs.flutter.io/flutter/painting/NetworkImage-class.html ?

– Günter Zöchbauer
Dec 31 '18 at 7:00





Why are you not using docs.flutter.io/flutter/painting/NetworkImage-class.html ?

– Günter Zöchbauer
Dec 31 '18 at 7:00













@GünterZöchbauer Maybe because he is new to this and doesn't know about it?

– zuckerburg
Dec 31 '18 at 7:01





@GünterZöchbauer Maybe because he is new to this and doesn't know about it?

– zuckerburg
Dec 31 '18 at 7:01













To use that library, I have to know the url of image and it leads to that have to extract that url in web page.

– baeharam
Dec 31 '18 at 7:01





To use that library, I have to know the url of image and it leads to that have to extract that url in web page.

– baeharam
Dec 31 '18 at 7:01













So you want to extract the URL, not the image.

– Günter Zöchbauer
Dec 31 '18 at 7:02





So you want to extract the URL, not the image.

– Günter Zöchbauer
Dec 31 '18 at 7:02













Yes, I edited plz see

– baeharam
Dec 31 '18 at 7:03





Yes, I edited plz see

– baeharam
Dec 31 '18 at 7:03












1 Answer
1






active

oldest

votes


















2














Here you have a basic example, after you press the top-right button, you will get the images in a ListView:



    import 'dart:async';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:html/parser.dart' as parser;
import 'package:html/dom.dart' as dom;


...create your StatefulWidget



class ParsingWidgetState extends State<ParsingWidget> {
List<String> list = List();

void _getData() async {
final response =
await http.get('https://comic.naver.com/webtoon/weekdayList.nhn?week=');
dom.Document document = parser.parse(response.body);
final elements = document.getElementsByClassName('thumb');

setState(() {
list = elements
.map((element) =>
element.getElementsByTagName("img")[0].attributes['src'])
.toList();
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
actions: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
onPressed: () {
_getData();
},
),
],
),
body: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
return Image.network(
list[index],
height: 200.0,
);
},
));
}
}


Try using FutureBuilder instead setState, this is just a working sample.



More info:




  • https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html

  • https://flutter-academy.com/async-in-flutter-futurebuilder/






share|improve this answer



















  • 1





    Wow, thanks!!!!

    – baeharam
    Dec 31 '18 at 7:11











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53984429%2fflutter-fetching-specfic-image-from-website%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Here you have a basic example, after you press the top-right button, you will get the images in a ListView:



    import 'dart:async';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:html/parser.dart' as parser;
import 'package:html/dom.dart' as dom;


...create your StatefulWidget



class ParsingWidgetState extends State<ParsingWidget> {
List<String> list = List();

void _getData() async {
final response =
await http.get('https://comic.naver.com/webtoon/weekdayList.nhn?week=');
dom.Document document = parser.parse(response.body);
final elements = document.getElementsByClassName('thumb');

setState(() {
list = elements
.map((element) =>
element.getElementsByTagName("img")[0].attributes['src'])
.toList();
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
actions: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
onPressed: () {
_getData();
},
),
],
),
body: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
return Image.network(
list[index],
height: 200.0,
);
},
));
}
}


Try using FutureBuilder instead setState, this is just a working sample.



More info:




  • https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html

  • https://flutter-academy.com/async-in-flutter-futurebuilder/






share|improve this answer



















  • 1





    Wow, thanks!!!!

    – baeharam
    Dec 31 '18 at 7:11
















2














Here you have a basic example, after you press the top-right button, you will get the images in a ListView:



    import 'dart:async';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:html/parser.dart' as parser;
import 'package:html/dom.dart' as dom;


...create your StatefulWidget



class ParsingWidgetState extends State<ParsingWidget> {
List<String> list = List();

void _getData() async {
final response =
await http.get('https://comic.naver.com/webtoon/weekdayList.nhn?week=');
dom.Document document = parser.parse(response.body);
final elements = document.getElementsByClassName('thumb');

setState(() {
list = elements
.map((element) =>
element.getElementsByTagName("img")[0].attributes['src'])
.toList();
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
actions: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
onPressed: () {
_getData();
},
),
],
),
body: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
return Image.network(
list[index],
height: 200.0,
);
},
));
}
}


Try using FutureBuilder instead setState, this is just a working sample.



More info:




  • https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html

  • https://flutter-academy.com/async-in-flutter-futurebuilder/






share|improve this answer



















  • 1





    Wow, thanks!!!!

    – baeharam
    Dec 31 '18 at 7:11














2












2








2







Here you have a basic example, after you press the top-right button, you will get the images in a ListView:



    import 'dart:async';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:html/parser.dart' as parser;
import 'package:html/dom.dart' as dom;


...create your StatefulWidget



class ParsingWidgetState extends State<ParsingWidget> {
List<String> list = List();

void _getData() async {
final response =
await http.get('https://comic.naver.com/webtoon/weekdayList.nhn?week=');
dom.Document document = parser.parse(response.body);
final elements = document.getElementsByClassName('thumb');

setState(() {
list = elements
.map((element) =>
element.getElementsByTagName("img")[0].attributes['src'])
.toList();
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
actions: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
onPressed: () {
_getData();
},
),
],
),
body: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
return Image.network(
list[index],
height: 200.0,
);
},
));
}
}


Try using FutureBuilder instead setState, this is just a working sample.



More info:




  • https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html

  • https://flutter-academy.com/async-in-flutter-futurebuilder/






share|improve this answer













Here you have a basic example, after you press the top-right button, you will get the images in a ListView:



    import 'dart:async';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:html/parser.dart' as parser;
import 'package:html/dom.dart' as dom;


...create your StatefulWidget



class ParsingWidgetState extends State<ParsingWidget> {
List<String> list = List();

void _getData() async {
final response =
await http.get('https://comic.naver.com/webtoon/weekdayList.nhn?week=');
dom.Document document = parser.parse(response.body);
final elements = document.getElementsByClassName('thumb');

setState(() {
list = elements
.map((element) =>
element.getElementsByTagName("img")[0].attributes['src'])
.toList();
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
actions: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
onPressed: () {
_getData();
},
),
],
),
body: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
return Image.network(
list[index],
height: 200.0,
);
},
));
}
}


Try using FutureBuilder instead setState, this is just a working sample.



More info:




  • https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html

  • https://flutter-academy.com/async-in-flutter-futurebuilder/







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 31 '18 at 7:04









diegoveloperdiegoveloper

12.2k11630




12.2k11630








  • 1





    Wow, thanks!!!!

    – baeharam
    Dec 31 '18 at 7:11














  • 1





    Wow, thanks!!!!

    – baeharam
    Dec 31 '18 at 7:11








1




1





Wow, thanks!!!!

– baeharam
Dec 31 '18 at 7:11





Wow, thanks!!!!

– baeharam
Dec 31 '18 at 7:11


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53984429%2fflutter-fetching-specfic-image-from-website%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







KS8x85n9iScsJTZx U9GGYEw,5qgPmH q2CKTm7z657iYOod,2 l,4ttlfKG,f,TIPmz
1KEVay,b RnfTa TbLTehmkgtx27S,e 5,R,8D 9 RXeW,M FrX

Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas