-
-
Save callmekohei/5c6fefa7ffee58890ad9d0bb163c5eeb to your computer and use it in GitHub Desktop.
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
#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