Skip to content

Instantly share code, notes, and snippets.

@callmekohei
Last active August 28, 2017 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save callmekohei/5c6fefa7ffee58890ad9d0bb163c5eeb to your computer and use it in GitHub Desktop.
Save callmekohei/5c6fefa7ffee58890ad9d0bb163c5eeb to your computer and use it in GitHub Desktop.
#r "./packages/FSharp.Data/lib/net40/FSharp.Data.dll"
open FSharp.Data
open System.Text.RegularExpressions
let args = fsi.CommandLineArgs
let url =
if Array.length args = 1 then
let s = System.DateTime.Now.ToString("yyyyMMdd")
@"http://kissfx.com/article/fxdays" + s + ".html"
else
@"http://kissfx.com/article/fxdays" + args.[1] + ".html"
Http.RequestString( url , responseEncodingOverride = "UTF-8")
|> HtmlDocument.Parse
|> fun doc ->
let update = doc.CssSelect( @"div.date")
|> List.map ( fun n -> n.InnerText() )
stdout.WriteLine("===== 羊飼いのブログ ( " + update.[0] + " ) =====\n")
doc.CssSelect( @"div.text" )
|> List.map ( fun n -> n.InnerText() )
|> List.exactlyOne
|> fun s -> Regex.Split(s, "毎日更新\)")
|> fun l -> l.[1]
|> fun s -> Regex.Split(s, "■□■本日のトレード用のエサ\(羊飼いの見解\)")
|> fun l -> l.[0]
|> fun s -> Regex.Split(s,"\n")
|> Array.map( fun s -> s.Trim())
|> Array.reduce(fun a b -> a + "\n" + b)
|> fun s -> Regex.Replace( s , "※" ,"*")
|> fun s -> Regex.Replace( s , "★" ,"***")
|> fun s -> Regex.Replace( s , "→" ,"-> ")
|> fun s -> s.Trim()
|> stdout.WriteLine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment