anchor.diff:              let dateStr = str |> removeTags
               DateTime.ParseExact(dateStr, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None)
          
  +        let urlDecode str =
  +            System.Net.WebUtility.UrlDecode str
  +
  +        member this.clearCookies =
  +            let cookies = cookieContainer.GetCookies(new Uri("http://www.dividend.com/"))
  +            for cookie in cookies do
  +                cookie.Expired <- true
  +
           member this.parse(json : string) =
               let data = jsonProv.Parse(json)
  -            data.Rows |> Seq.map this.parseRow
  +            (data.Total, data.Rows |> Seq.map this.parseRow)
                           
           member this.parseRow(row) =
               new Dividend(
  -                Amount = row.Payout,
  -                Symbol = (row.Symbol |> removeTags),
  -                PaymentDate = (row.PayDate |> parseNullableDate),
  +                Amount = row.Amount,
  +                Symbol = (row.Symbol |> urlDecode |> removeTags),
  +                PaymentDate = (row.Paydate |> urlDecode |> removeTags |> parseNullableDate),
                   Currency = "USD",
  -                ExDate = parseDate(row.ExDivDate))
  -
  -        member this.getDividends(request : DividendRequest) = 
  +                ExDate = (row.Exdivdate |> urlDecode |> removeTags |> parseDate))
  +        
  +        member this.dividendSubRequest(request : DividendRequest, offset : int) = 
               async {
  -                let url = sprintf "http://www.dividend.com/data_set/?tm=30&cond={\"by_active\":null,\"by_ex_dividend_date\":[\"%s\",\"%s\"],\"by_stock_type\":{\"Preferred\":\"on\",\"ADR\":\"on\",\"ETF\":\"on\",\"ETN\":\"on\",\"Fund\":\"on\",\"SeniorNotes\":\"on\",\"common_shares\":\"on\"}}&no_null_sort=true&count_by_id=&sort=ex_div_date&order=ASC&limit=10000&offset=0" (request.FromDate.ToString("yyyy-MM-dd")) (request.ToDate.ToString("yyyy-MM-dd"))
  -                logger.Info("Downloading dividends from " + url)
  -
  +                let url = sprintf "http://www.dividend.com/data_set/?tm=362&cond={\"by_active\":null,\"by_ex_div_date\":[\"%s\",\"%s\"],\"by_stock_type\":{\"Preferred\":\"on\",\"ADR\":\"on\",\"ETF\":\"on\",\"ETN\":\"on\",\"Fund\":\"on\",\"REIT\":\"on\",\"SeniorNotes\":\"on\",\"common_stock\":\"on\"}}&no_null_sort=true&count_by_id=" (request.FromDate.ToString("yyyy-MM-dd")) (request.ToDate.ToString("yyyy-MM-dd"))
  +                logger.Info("Downloading dividends from " + url + " offset " + offset.ToString()) //TODO the problem is that the broker doesn't surface the error...
  +
  +                let req = new HttpRequestMessage()
  +                req.Method <- System.Net.Http.HttpMethod.Get
  +                req.RequestUri <- new Uri(url)
  +                req.Content <- new StringContent(sprintf "{\"limit\":11,\"offset\":%i,\"order\":\"ASC\",\"sort\":\"exdivdate\"}" offset, System.Text.Encoding.UTF8, "application/json")
                   let! httpResponse = httpClient.GetAsync(url) |> Async.AwaitTask
                   httpResponse.EnsureSuccessStatusCode() |> ignore
                   let! json = httpResponse.Content.ReadAsStringAsync() |> Async.AwaitTask
  -                return json 
  -                    //|> System.Text.RegularExpressions.Regex.Unescape
  -                    |> this.parse
  -                    |> System.Collections.Generic.List<Dividend>
  +                return json |> this.parse
  +            }
  +
  +        member this.getDividends(request : DividendRequest) = 
  +            async {
  +                //do a first request which gets the total, then loop grabbing 10 items each time
  +                let divs = new System.Collections.Generic.List<Dividend>()
  +                let! (total, rows) = this.dividendSubRequest(request, 0)
  +                logger.Info(sprintf "Getting %i dividends" total)
  +                divs.AddRange(rows)
  +                let mutable counter = 10
  +                while counter < total do
  +                    let! (_, rows) = this.dividendSubRequest(request, counter)
  +                    counter <- counter + 10
  +                    divs.AddRange(rows)
  +                    this.clearCookies
  +                    do! Async.Sleep(rand.Next(1050, 2000))
  +
  +                return divs
               }
               //todo if specified symbol, throw
           interface IDividendDataSource with
  
positive.code:     open System.Globalization
      //sometimes not entirely correct dividend values...
      type jsonProv = FSharp.Data.JsonProvider<""" 	
      {
      "total": 223,
  	"rows": [
  		{
  			"symbol": "<a href=\"/dividend-stocks/financial/closed-end-fund-equity/gab-gabelli-equity-trust-inc/\"><span class=\"caps\">GAB</span></a>",
  			"_symbol_data": {
  				"th": "Stock Symbol"
  			},
  			"name": "<a href=\"/dividend-stocks/financial/closed-end-fund-equity/gab-gabelli-equity-trust-inc/\">Gabelli Equity Trust Inc.</a>",
  			"_name_data": {
  				"th": "Company Name"
  			},
  			"dars_rating": "<a href='/premium/signup.php' class='restricted' style='vertical-align: middle;'></a>",
  			"_dars_rating_data": {
  				"th": "DARS™ Rating"
  			},
  			"ex_div_date": "<span style=\"white-space: nowrap;margin-right: 20px;\">2017-06-15</span>",
  			"_ex_div_date_data": {
  				"th": "Ex-Div Date"
  			},
  			"pay_date": "<span style=\"white-space: nowrap;\">2017-06-26</span>",
  			"_pay_date_data": {
  				"th": "Pay Date"
  			},
  			"payout": "0.15",
  			"_payout_data": {
  				"th": "Div Payout"
  			},
  			"qualification": "Unknown",
  			"_qualification_data": {
  				"th": "Qualified Dividend?"
  			},
  			"price": "$6.13",
  			"_price_data": {
  				"th": "Stock Price"
  			},
  			"dividend_yield": "9.79%",
  			"_dividend_yield_data": {
  				"th": "Yield"
  			}
  		}
  ]
  }
   """>
  
      type DividendDotCom() = 
          let error = Event<EventHandler<ErrorArgs>,ErrorArgs>()
          let logger = NLog.LogManager.GetCurrentClassLogger()
          let httpClient = new HttpClient()
          do
              httpClient.DefaultRequestHeaders.Add("Referer", "http://www.dividend.com/ex-dividend-dates.php");
  
  
negative.code:                         return! this.getDividends(request)
                      with e -> 
                              logger.Error(e, "Error downloading dividend data: " + e.Message)
                              error.Trigger(this, new ErrorArgs(0, e.Message))
                              return System.Collections.Generic.List<Dividend>()
                  } |> Async.StartAsTask