mirror of
				https://github.com/h7x4/unofficial_jisho_api_dart.git
				synced 2025-10-31 01:43:36 +01:00 
			
		
		
		
	Add examples for direct parsing
This commit is contained in:
		| @@ -6,7 +6,7 @@ void main() async { | ||||
|     print('Jisho Uri: ' + result.uri); | ||||
|     print(''); | ||||
| 
 | ||||
|     for (int i = 0; i < 3; i++) { | ||||
|     for (var i = 0; i < 3; i++) { | ||||
|       var example = result.results[i]; | ||||
|       print(example.kanji); | ||||
|       print(example.kana); | ||||
							
								
								
									
										17
									
								
								example/parser/parse_example_page.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								example/parser/parse_example_page.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| import 'package:http/http.dart' as http; | ||||
| import 'dart:convert'; | ||||
| import 'package:unofficial_jisho_api/parser.dart' as jisho_parser; | ||||
|  | ||||
| final encoder = JsonEncoder.withIndent('  '); | ||||
|  | ||||
| const SEARCH_EXAMPLE = '保護者'; | ||||
| final SEARCH_URI = jisho_parser.uriForExampleSearch(SEARCH_EXAMPLE); | ||||
|  | ||||
| void main() async { | ||||
|   await http.get(SEARCH_URI).then((result) { | ||||
|     final parsedResult = jisho_parser.parseExamplePageHtml(result.body, SEARCH_EXAMPLE); | ||||
|     print('English: ${parsedResult.results[0].english}'); | ||||
|     print('Kanji ${parsedResult.results[0].kanji}'); | ||||
|     print('Kana: ${parsedResult.results[0].kana}'); | ||||
|   }); | ||||
| } | ||||
							
								
								
									
										17
									
								
								example/parser/parse_kanji_page.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								example/parser/parse_kanji_page.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| import 'package:http/http.dart' as http; | ||||
| import 'dart:convert'; | ||||
| import 'package:unofficial_jisho_api/parser.dart' as jisho_parser; | ||||
|  | ||||
| final encoder = JsonEncoder.withIndent('  '); | ||||
|  | ||||
| const SEARCH_KANJI = '車'; | ||||
| final SEARCH_URI = jisho_parser.uriForKanjiSearch(SEARCH_KANJI); | ||||
|  | ||||
| void main() async { | ||||
|   await http.get(SEARCH_URI).then((result) { | ||||
|     final parsedResult = jisho_parser.parseKanjiPageHtml(result.body, SEARCH_KANJI); | ||||
|     print('JLPT level: ${parsedResult.jlptLevel}'); | ||||
|     print('Stroke count: ${parsedResult.strokeCount}'); | ||||
|     print('Meaning: ${parsedResult.meaning}'); | ||||
|   }); | ||||
| } | ||||
							
								
								
									
										16
									
								
								example/parser/parse_phrase_page.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								example/parser/parse_phrase_page.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| import 'package:http/http.dart' as http; | ||||
| import 'dart:convert'; | ||||
| import 'package:unofficial_jisho_api/parser.dart' as jisho_parser; | ||||
|  | ||||
| final encoder = JsonEncoder.withIndent('  '); | ||||
|  | ||||
| const SEARCH_EXAMPLE = '保護者'; | ||||
| final SEARCH_URI = jisho_parser.uriForPhraseScrape(SEARCH_EXAMPLE); | ||||
|  | ||||
| void main() async { | ||||
|  | ||||
|   await http.get(SEARCH_URI).then((result) { | ||||
|     final parsedResult = jisho_parser.parsePhraseScrapeHtml(result.body, SEARCH_EXAMPLE); | ||||
|     print(encoder.convert(parsedResult)); | ||||
|   }); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user