// ad permision android minefist
//
//
getdata() async {
// Make an HTTP GET request to a URL
var response =
await http.get(Uri.parse('https://ex.co/'));
// Parse the response as HTML
var document = parse(response.body);
Directory? dir = await getExternalStorageDirectory();
print(dir!.path);
// Select elements from the HTML document
var link = document
.querySelectorAll('#pt-cv-view-c197f60kdt > div > div > div > h4');
var ss = document
.querySelectorAll('#pt-cv-view-c197f60kdt > div > div > div > h4 > a')
.map((e) => e.attributes['href'].toString())
.toList();
var myap = {
"data": List.generate(link.length, (index) {
return {"chapter": link[index].text};
})
};
var filee = File('${dir.path}/main.json');
await filee.writeAsString(jsonEncode(myap));
// log(myap.toString());
// ignore: unused_local_variable
for (var i = 0; i < 1;) {
log('${dir.path}/${link[i].text.toString()}.json');
var file = File('${dir.path}/${link[i].text.toString()}.json');
var response = await http.get(Uri.parse(ss[i]));
// Parse the response as HTML
var document = parse(response.body);
// Select elements from the HTML document
var datali = document
.getElementsByClassName('entry-content clr')[0]
.innerHtml;
var data = {'title': link[i].text, 'data': datali.toString()};
await file.writeAsString(jsonEncode(data));
i++;
}