linkfo 0.0.3 linkfo: ^0.0.3 copied to clipboard
Crawls and gathers open graph and twitter cards information from links
linkfo #
Retrieve basic information from links
Getting Started #
install linkfo
:
linkfo: <latest_version>
Linkfo uses sealed unions to handle the case of possible matches:
const url = 'https://www.youtube.com/watch?v=45MIykWJ-C4';
final response = await client.get(Uri.parse(url));
final scraper = TwitterCardsScraper(body: response.body, url: url);
final info = scraper.scrape();
info.map(
app: (_) {
// ...
},
summaryLargeImage: (_) {
// ...
},
player: (playerInfo) {
print(playerInfo.title);
print(playerInfo.player);
},
summary: (_) {
// ...
},
);
const url = 'https://www.imdb.com/title/tt0117500/';
final response = await client.get(Uri.parse(url));
final scraper = OpenGraphScraper(body: response.body, url: url);
final info = scraper.scrape();
expect(info.description, isNotNull);
expect(info.image, isNotNull);
expect(info.title, isNotNull);
If you intend to match all possible cases, you can go so far as to prepare for all cases:
const url = 'https://www.youtube.com/watch?v=45MIykWJ-C4';
final response = await client.get(Uri.parse(url));
final info = Scraper.parse(body: response.body, url: url);
info.maybeWhen(
openGraph: (info) {
print(info.description);
print(info.image);
print(info.title);
},
twitterCards: (_) {
// ...
},
orElse: () {
// ...
},
);
Currently the only supported parsers are Amazon (ish), Open Graph and Twitter Cards.
Note #
This api is in early development and might change drastically as I look for the best way to return parsed information.
PRs and Issues welcome