77
88import java .io .IOException ;
99import java .io .InputStream ;
10- import java .io .UnsupportedEncodingException ;
1110import java .net .URL ;
1211import java .net .URLConnection ;
1312import java .net .URLEncoder ;
13+ import java .nio .charset .StandardCharsets ;
1414import java .time .LocalDate ;
1515import java .time .ZoneId ;
1616import java .util .HashMap ;
@@ -26,18 +26,18 @@ public abstract class AbstractYahooService {
2626
2727 protected final Logger logger = LoggerFactory .getLogger (this .getClass ());
2828
29- protected Map <String , String > getRequestParams (LocalDate from , LocalDate to , StandardPeriodType periodType ) throws IOException , StockServiceException {
29+ protected Map <String , String > getRequestParams (LocalDate from , LocalDate to , StandardPeriodType periodType ) throws StockServiceException {
3030 Map <String , String > params = new LinkedHashMap <>();
3131 params .put ("period1" , String .valueOf (toSeconds (from )));
3232 params .put ("period2" , String .valueOf (toSeconds (to )));
3333 params .put ("interval" , getPeriodCode (periodType ));
3434 // crumb
35- params .put ("crumb" , CrumbManager .getCrumb ());
35+ // params.put("crumb", CrumbManager.getCrumb());
3636 return params ;
3737 }
3838
3939 protected InputStream getUrlStream (String symbol , Map <String , String > params ) throws IOException {
40- String url = HISTQUOTES2_BASE_URL + URLEncoder .encode (symbol , "UTF-8" ) + "?" + getURLParameters (params );
40+ String url = HISTQUOTES2_BASE_URL + URLEncoder .encode (symbol , StandardCharsets . UTF_8 ) + "?" + getURLParameters (params );
4141
4242 // Get CSV from Yahoo
4343 logger .info ("Sending request: {}" , url );
@@ -47,21 +47,21 @@ protected InputStream getUrlStream(String symbol, Map<String, String> params) th
4747 redirectableRequest .setConnectTimeout (CONNECTION_TIMEOUT );
4848 redirectableRequest .setReadTimeout (CONNECTION_TIMEOUT );
4949 Map <String , String > requestProperties = new HashMap <>();
50- requestProperties .put ("Cookie" , CrumbManager .getCookie ());
50+ // requestProperties.put("Cookie", CrumbManager.getCookie());
5151 URLConnection connection = redirectableRequest .openConnection (requestProperties );
5252 return connection .getInputStream ();
5353 }
5454
55- private String getURLParameters (Map <String , String > params ) throws UnsupportedEncodingException {
55+ private String getURLParameters (Map <String , String > params ) {
5656 StringBuilder sb = new StringBuilder ();
5757 for (Entry <String , String > entry : params .entrySet ()) {
5858 if (sb .length () > 0 ) {
5959 sb .append ("&" );
6060 }
6161 String key = entry .getKey ();
6262 String value = entry .getValue ();
63- key = URLEncoder .encode (key , "UTF-8" );
64- value = URLEncoder .encode (value , "UTF-8" );
63+ key = URLEncoder .encode (key , StandardCharsets . UTF_8 );
64+ value = URLEncoder .encode (value , StandardCharsets . UTF_8 );
6565 sb .append (String .format ("%s=%s" , key , value ));
6666 }
6767 return sb .toString ();
0 commit comments