Created
July 19, 2020 07:25
-
-
Save apgapg/ebfaae6be8891a2917db8016f3050be4 to your computer and use it in GitHub Desktop.
Scrap data from website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void initChaptersTitleScrap() async { | |
final rawUrl = | |
'https://unacademy.com/course/gravitation-for-iit-jee/D5A8YSAJ'; | |
final webScraper = WebScraper('https://unacademy.com'); | |
final endpoint = rawUrl.replaceAll(r'https://unacademy.com', ''); | |
if (await webScraper.loadWebPage(endpoint)) { | |
final titleElements = webScraper.getElement( | |
'div.Week__Wrapper-sc-1qeje5a-2 > a.Link__StyledAnchor-sc-1n9f3wx-0 ' | |
'> div.ItemCard__ItemInfo-xrh60s-1 ' | |
'> h6.H6-sc-1gn2suh-0', | |
[]); | |
print(titleElements); | |
final titleList = <String>[]; | |
titleElements.forEach((element) { | |
final title = element['title']; | |
titleList.add('$title'); | |
}); | |
print(titleList); | |
if (mounted) | |
setState(() { | |
this.titleList = titleList; | |
}); | |
} else { | |
print('Cannot load url'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment