-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## Basic usage | ||
|
||
The original aim of this package is to help scrapping expat.cz articles as such: | ||
|
||
```golang | ||
func main() { | ||
link, err := scraper.FindLinkWith("weekend", scraper.BaseURL) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
ct, err := scraper.GetArticleContent(link) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
file, err := os.Create("events.json") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
err = json.NewEncoder(file).Encode(ct) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
``` | ||
giving result like this | ||
```json | ||
{ | ||
"Content": "On May 18, peruse military equipment and weapons at Atrium Flora, which will be transformed into a military base...", | ||
"Title": "MILITARY MARVELS " | ||
} | ||
``` |