Add an additional method to the SeekingAlpha news feed.
This commit is contained in:
@@ -1706,8 +1706,9 @@ namespace MarketData.Helper
|
||||
// ***************************************************************************************************************************************************************************
|
||||
public static Headlines GetCompanyHeadlinesSeekingAlpha(String symbol)
|
||||
{
|
||||
Headlines headlines = GetCompanyHeadlinesSeekingAlphaV1(symbol);
|
||||
if(null==headlines || 0==headlines.Count)headlines= GetCompanyHeadlinesSeekingAlphaV2(symbol);
|
||||
Headlines headlines = GetCompanyHeadlinesSeekingAlphaV3(symbol);
|
||||
if (null == headlines || 0 == headlines.Count) headlines = GetCompanyHeadlinesSeekingAlphaV1(symbol);
|
||||
if (null == headlines || 0 == headlines.Count) headlines = GetCompanyHeadlinesSeekingAlphaV2(symbol);
|
||||
return headlines;
|
||||
}
|
||||
|
||||
@@ -1846,6 +1847,97 @@ namespace MarketData.Helper
|
||||
}
|
||||
}
|
||||
|
||||
public static Headlines GetCompanyHeadlinesSeekingAlphaV3(String symbol)
|
||||
{
|
||||
HttpNetResponse httpNetResponse=null;
|
||||
Headlines headlines=new Headlines();
|
||||
|
||||
try
|
||||
{
|
||||
String domain = "seekingalpha.com";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String strRequest;
|
||||
symbol = symbol.ToUpper();
|
||||
|
||||
// Visit the home page
|
||||
WebProxy webProxy=HttpNetRequest.GetProxy("GetCompanyHeadlinesSeekingAlphaV3");
|
||||
sb.Append("https://").Append(domain);
|
||||
|
||||
httpNetResponse=HttpNetRequest.GetRequestNoEncodingV5D(sb.ToString(),domain,30000,webProxy,false);
|
||||
if(!httpNetResponse.Success)return null;
|
||||
CookieCollection cookieCollection = httpNetResponse.CookieCollection;
|
||||
|
||||
sb=new StringBuilder();
|
||||
DateTime marketDate=PremarketDA.GetLatestMarketDate();
|
||||
if(Utility.IsEpoch(marketDate))marketDate=DateTime.Now;
|
||||
|
||||
#region Create Cookies
|
||||
|
||||
StringBuilder lastVisitedPage = new StringBuilder();
|
||||
lastVisitedPage.Append("%7B%22pathname%22%3A%22https%3A%2F%2Fseekingalpha.com%2Fsymbol%2F");
|
||||
lastVisitedPage.Append(symbol);
|
||||
lastVisitedPage.Append("%2Fnews%22%2C%22pageKey%22%3A%22947f55ae-51ad-480f-9f22-54ef1d5904d1%22%7D");
|
||||
|
||||
cookieCollection.Add(new Cookie("LAST_VISITED_PAGE", lastVisitedPage.ToString()) { Domain = domain });
|
||||
cookieCollection.Add(new Cookie("_ga", "GA1.1.1862228764.1739274352") { Domain = domain });
|
||||
cookieCollection.Add(new Cookie("_ga_KGRFF2R2C5","GS1.1.1739274352.1.1.1739274637.60.0.0"){ Domain = domain });
|
||||
cookieCollection.Add(new Cookie("_gcl_au","1.1.1611738349.1739274352"){ Domain = domain });
|
||||
cookieCollection.Add(new Cookie("_pxvid","bfabea2f-e86d-11ef-832d-24c9f227f821"){ Domain = domain });
|
||||
cookieCollection.Add(new Cookie("_sasource",""){ Domain = domain });
|
||||
cookieCollection.Add(new Cookie("pxcts","bfabfefc-e86d-11ef-832f-7d1e5f897eb5"){ Domain = domain });
|
||||
|
||||
#endregion
|
||||
sb.Append("https://").Append(domain).Append("/api/v3/symbols/").Append(symbol).Append("/news?filter[since]=");
|
||||
// sb.Append(marketDate.Year).Append("-").Append(Utility.Pad(marketDate.Month.ToString(), '0', 2)).Append("-").Append(Utility.Pad(marketDate.Day.ToString(), '0', 2));
|
||||
// sb.Append("T04%3A00%3A00.000Z");
|
||||
sb.Append("0");
|
||||
sb.Append("&filter[until]=");
|
||||
// sb.Append(marketDate.Year).Append("-").Append(Utility.Pad(marketDate.Month.ToString(), '0', 2)).Append("-").Append(Utility.Pad(marketDate.Day.ToString(), '0', 2));
|
||||
// sb.Append("T14%3A20%3A34.999Z");
|
||||
sb.Append("0");
|
||||
sb.Append("&id=").Append(symbol);
|
||||
sb.Append("&include=author,primaryTickers,secondaryTickers,sentiments,otherTags&isMounting=true&page[size]=40&page[number]=1");
|
||||
strRequest = sb.ToString();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, strRequest);
|
||||
|
||||
httpNetResponse=HttpNetRequest.GetRequestNoEncodingV5D(strRequest,domain,30000,webProxy,false,cookieCollection);
|
||||
|
||||
if(!httpNetResponse.Success)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Request:{0} failed with status {1}",httpNetResponse.Request,httpNetResponse.StatusCode));
|
||||
return null;
|
||||
}
|
||||
byte[] streamBytes = Encoding.ASCII.GetBytes(httpNetResponse.ResponseString);
|
||||
List<KeyValue> keyValuePairs = MarketDataHelper.LocateJSONKeyValuePairs(httpNetResponse.ResponseString, "\"publishOn\"", "\"title\"");
|
||||
if(null==keyValuePairs)return null;
|
||||
|
||||
foreach (KeyValue keyValue in keyValuePairs)
|
||||
{
|
||||
Headline headline=null;
|
||||
if (keyValue.Value.StartsWith("Video")) headline = new Headline(symbol, Utility.ParseDate(keyValue.Key.Substring(0, keyValue.Key.IndexOf('T'))),Uri.UnescapeDataString(keyValue.Value));
|
||||
else headline = new Headline(symbol, Utility.ParseDate(keyValue.Key.Substring(0, keyValue.Key.IndexOf('T'))), keyValue.Value);
|
||||
headline.Entry=headline.Entry.Replace("\\"," ");
|
||||
headline.Entry=headline.Entry.Trim();
|
||||
headline.Entry=Encoding.UTF8.GetString(Encoding.Default.GetBytes(headline.Entry));
|
||||
headline.Entry=Uri.UnescapeDataString(headline.Entry);
|
||||
headline.Source = "Seeking Alpha";
|
||||
headlines.Add(headline);
|
||||
}
|
||||
headlines = new Headlines(headlines.Where(x => x.Date.Date.Equals(marketDate.Date)).ToList());
|
||||
|
||||
return headlines;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,exception.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(null!=httpNetResponse)httpNetResponse.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************************************************************************************************************
|
||||
//***************************************************************** H E A D L I N E S - M A R K E T W A T C H *************************************************************
|
||||
// ***************************************************************************************************************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user