search steam store
This commit is contained in:
commit
fe419d7705
2
dune-project
Normal file
2
dune-project
Normal file
|
@ -0,0 +1,2 @@
|
|||
(lang dune 2.5)
|
||||
(name vg-store)
|
28
src/main.ml
Normal file
28
src/main.ml
Normal file
|
@ -0,0 +1,28 @@
|
|||
open Mechaml
|
||||
module M = Agent.Monad
|
||||
open M.Infix
|
||||
|
||||
let require msg = function
|
||||
| Some a -> a
|
||||
| None -> failwith msg
|
||||
|
||||
let steam_search query =
|
||||
let url = "https://store.steampowered.com/" in
|
||||
Agent.get url
|
||||
>|= (fun result ->
|
||||
let form = result
|
||||
|> Agent.HttpResponse.page
|
||||
|> Page.form_with "[id=searchform]"
|
||||
|> require "search form not found" in
|
||||
let field = form
|
||||
|> Page.Form.field_with "[name=term]"
|
||||
|> require "q field not found" in
|
||||
Page.Form.Field.set form field query)
|
||||
>>= Agent.submit
|
||||
>>= (fun response ->
|
||||
response
|
||||
|> Agent.HttpResponse.content
|
||||
|> M.save_content "steam-result.html")
|
||||
|
||||
let _ =
|
||||
M.run (Agent.init ()) (steam_search "planet")
|
18
vg-store.opam
Normal file
18
vg-store.opam
Normal file
|
@ -0,0 +1,18 @@
|
|||
opam-version: "2.0"
|
||||
name: "vg-store"
|
||||
version: "~dev"
|
||||
synopsis: "Quickly check games on multiple stores"
|
||||
maintainer: "Fabien Freling <public@ffreling.com>"
|
||||
authors: "Fabien Freling <public@ffreling.com>"
|
||||
license: "MIT"
|
||||
homepage: "http://code.ffreling.com/fabs/vg-store"
|
||||
bug-reports: "http://code.ffreling.com/fabs/vg-store/issues"
|
||||
depends: [
|
||||
"mechaml"
|
||||
"lwt_ssl"
|
||||
]
|
||||
build: ["dune" "build" "-p" name "-j" jobs]
|
||||
dev-repo: "git+http://code.ffreling.com/fabs/vg-store"
|
||||
url {
|
||||
src: "http://code.ffreling.com/fabs/vg-store"
|
||||
}
|
Loading…
Reference in a new issue