insta_html_parser 0.0.2 insta_html_parser: ^0.0.2 copied to clipboard
Provides the profile data of a given instagram url profile.
insta_html_parser #
A package developed to retrieve data from instagram profiles.
This should not be used for professional purposes.
If you wish, take a look at the official Instagram API.
Preview #
Example #
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:insta_html_parser/insta_html_parser.dart';
void main() {
runApp(InstaParserExampleApp());
}
class InstaParserExampleApp extends StatefulWidget {
final GlobalKey<ScaffoldState> scaffoldKey;
InstaParserExampleApp({Key key, this.scaffoldKey}) : super(key: key);
@override
_InstaParserExampleAppState createState() => _InstaParserExampleAppState();
}
class _InstaParserExampleAppState extends State<InstaParserExampleApp> {
var _scaffoldKey = new GlobalKey<ScaffoldState>();
TextEditingController _profileUrlController = TextEditingController();
TextEditingController _postUrlController = TextEditingController();
TextStyle _textStyleBold = TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold);
TextStyle _textStyleUrl = TextStyle(fontSize: 16.0);
List<Widget> _parsedWidgets = [];
@override
Widget build(BuildContext context) {
return MaterialApp(
color: Colors.blue,
title: 'InstaParser',
home: Scaffold(
key: _scaffoldKey,
backgroundColor: Colors.purple[100],
appBar: AppBar(title: Text('InstaParser'), backgroundColor: Colors.purple[600],),
body: Center(
child: ListView(
children: [
Container( // Profile url input field
padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 16.0, bottom: 16.0),
child: Form(
child: TextFormField(
controller: _profileUrlController,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 2.0, bottom: 2.0),
labelText: 'Profile URL',
labelStyle: _textStyleUrl,
hintText: 'https://www.instagram.com/PROFILE_ID/',
hintStyle: TextStyle(color: Colors.grey[500], fontSize: 13)
)
)
)
),
Container( // Posts submit button
padding: EdgeInsets.only(left: 64.0, right: 64.0, bottom: 16.0),
child: RaisedButton(
child: Text('Parse posts', style: _textStyleUrl,),
onPressed: () async {
List<Widget> _widgetsList = [];
List<String> _postsUrls = await InstaParser.parsePostsUrlsFromInstaProfile('${_profileUrlController.text}');
for (int i = 3; i < _postsUrls.length; i++) {
// Divider
_widgetsList.add(
Container(padding: EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Divider(height: 0.0, color: Colors.black)
)
);
// Post URL
_widgetsList.add(Text('Post ${i-2}:', style: _textStyleBold));
_widgetsList.add(
GestureDetector(
child: Text('${_postsUrls[i]}', style: _textStyleUrl,),
onTap: () async {
setState(() {});
Clipboard.setData(ClipboardData(text: '${_postsUrls[i]}'));
_scaffoldKey.currentState.showSnackBar(SnackBar(content: Text("Copied post url")));
}
)
);
if (i == _postsUrls.length-1) {
_widgetsList.add(Padding(padding: EdgeInsets.only(bottom: 8.0),));
}
}
setState(() => _parsedWidgets = _widgetsList);
}
),
),
Container( // Post url input field
padding: EdgeInsets.only(left: 16.0, right: 16.0, top: 16.0, bottom: 16.0),
child: Form(
child: TextFormField(
controller: _postUrlController,
decoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 2.0, bottom: 2.0),
labelText: 'Post URL',
labelStyle: _textStyleUrl,
hintText: 'https://www.instagram.com/p/POST_ID',
hintStyle: TextStyle(color: Colors.grey[500], fontSize: 13)
)
)
)
),
Row( // Photos and video submit button
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container( // Parse photos
padding: EdgeInsets.only(left: 0.0, right: 0.0, bottom: 16.0),
child: RaisedButton(
child: Text('Parse photos', style: _textStyleUrl,),
onPressed: () async {
List<Widget> _widgetsList = [];
Map<String, String> photosUrls = await InstaParser.parsePhotosUrlsFromInstaPost('${_postUrlController.text}');
// Post URL
_widgetsList.add(Text('Post:', style: _textStyleBold));
_widgetsList.add(Text('${_postUrlController.text}', style: _textStyleUrl,));
// Divider
_widgetsList.add(
Container(padding: EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Divider(height: 0.0, color: Colors.black)
)
);
// Small photo URL
_widgetsList.add(Text('SmallPhoto:', style: _textStyleBold));
_widgetsList.add(
GestureDetector(
child: Text('${photosUrls['small']}\n', style: _textStyleUrl,),
onTap: () async {
setState(() {});
Clipboard.setData(ClipboardData(text: '${photosUrls['small']}'));
_scaffoldKey.currentState.showSnackBar(SnackBar(content: Text("Copied small size photo url")));
}
)
);
// Medium photo URL
_widgetsList.add(Text('MediumPhoto:', style: _textStyleBold));
_widgetsList.add(
GestureDetector(
child: Text('${photosUrls['medium']}\n', style: _textStyleUrl,),
onTap: () async {
setState(() {});
Clipboard.setData(ClipboardData(text: '${photosUrls['small']}'));
_scaffoldKey.currentState.showSnackBar(SnackBar(content: Text("Copied medium size photo url")));
}
)
);
// Large photo URL
_widgetsList.add(Text('LargePhoto:', style: _textStyleBold));
_widgetsList.add(
GestureDetector(
child: Text('${photosUrls['large']}\n', style: _textStyleUrl,),
onTap: () async {
setState(() {});
Clipboard.setData(ClipboardData(text: '${photosUrls['small']}'));
_scaffoldKey.currentState.showSnackBar(SnackBar(content: Text("Copied large size photo url")));
}
)
);
setState(() => _parsedWidgets = _widgetsList);
},
),
),
Container( // Parse video
padding: EdgeInsets.only(left: 0.0, right: 0.0, bottom: 16.0),
child: RaisedButton(
child: Text('Parse video', style: _textStyleUrl,),
onPressed: () async {
List<Widget> _widgetsList = [];
String _videoUrl = await InstaParser.parseVideoUrlFromInstaPost('${_postUrlController.text}');
// Post URL
_widgetsList.add(Text('Post:', style: _textStyleBold));
_widgetsList.add(Text('${_postUrlController.text}', style: _textStyleUrl,));
// Divider
_widgetsList.add(
Container(padding: EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Divider(height: 0.0, color: Colors.black)
)
);
// Video URL
_widgetsList.add(Text('Video:', style: _textStyleBold));
_widgetsList.add(
GestureDetector(
child: Text('$_videoUrl\n', style: _textStyleUrl,),
onTap: () async {
setState(() {});
Clipboard.setData(ClipboardData(text: '$_videoUrl'));
_scaffoldKey.currentState.showSnackBar(SnackBar(content: Text("Copied video url")));
}
)
);
setState(() => _parsedWidgets = _widgetsList);
},
),
),
],
),
Column(children: _parsedWidgets),
]
),
) ,
)
);
}
}