This API provides several implementations for parsing data from HLTV. To choose one replace controllers in strategy when creating instance of API in main.go or implement your own.
Note: Using ActualImplementation may result in bottleneck because of delay between requests to website or you will get temporarily banned. I recommend using StoredImplementation.
- Define address and port for API server
- Choose implementation of parsing data
- If you selected StoredImplementation, add database configuration (Connection string and driver name)
All controllers start goroutine to periodically (every 5 minutes) poll pages on HLTV and parse data (even if it didn't change).
It uses store (currently database, but you can implement your own class for repositories. For example: storing data in files or another database).
When new request come, controller form response from the data in store. So the time between actual and stored info is around 5 minutes.
To collect data from finished events or matches, run this.
When new request come, it forms the url and parse the data from the page. Then response is returned.
function | time | memory | allocs |
---|---|---|---|
ParseEvent | 1,829,307,000 ns/op | 4,129,744 B/op | 18,994 allocs/op |
ParseMatch | 40,668,946 ns/op | 5,280,532 B/op | 76,710 allocs/op |
ParseTeam | 55,601,717 ns/op | 11,166,684 B/op | 71,360 allocs/op |
ParsePlayer | 19,932,157 ns/op | 4,352,330 B/op | 23,424 allocs/op |
Parser | Rate |
---|---|
Event | 83.3% |
Match | 83.5% |
Team | 86.7% |
Player | 82.0% |
Other ~17% of coverage rate is checking error for nil:
if err != nil {
return nil, err
}