Reading in stock data from a website?

1 view (last 30 days)
I'm trying to use an existing .m file from a user (https://www.mathworks.com/matlabcentral/fileexchange/41940-james-o-shaughnessey-s-trending-value-screener). It appears that the file no longer is reading in data from a URL. The file hangs indefinitely until it is manually terminated. It appears no data is being read in. I'm not familiar with any of the java functions and reading the help files hasn't really helped much. Any suggestions or help would be appreciated. Thank you!
  2 Comments
Geoff Hayes
Geoff Hayes on 5 Dec 2018
Travis - have you tried stepping through the code to see what is happening? The stock URL (http://finviz.com/screener.ashx?v=152&f=cap_smallover&ft=4&c=0,1,2,6,7,10,11,13,14,45,65) is valid so it could be that there is a lot of data that has to be parsed (from the link, there appears to be about 176 pages and this code presumably reads each one).
Kevin Chng
Kevin Chng on 6 Dec 2018
Or if you have datafeed toolbox, you may fetch data from those financial platform : bloomberg, fred, havar analytica, reuter thomson,...However, this web is not in the list of datafeed toolbox : https://finviz.com/screener.ashx?v=152&f=cap_smallover&ft=4&c=0,1,2,6,7,10,11,13,14,45,65

Sign in to comment.

Accepted Answer

Travis L
Travis L on 7 Dec 2018
I was able to figure out the issue. It was an issue with the URL needing to be https instead of http. The web browser was taking care of it, but there was an issue reading from the MATLAB file without the correct https. I appreciate the suggestions.
  3 Comments
Travis L
Travis L on 7 May 2020
Hey Gianni, did you change all four instances of URLs to https? Do you get any output in the command window? I just verified that mine still runs. I have had issues in the past where I get similar failures midway through running. I believe it's an error on URL side or with the java retrieval. When I encounter this, I modify the code to continue running where it failed and that usually works.
Simon Prüller
Simon Prüller on 25 Feb 2021
Hallo Travis, do you know how i can add a 'User-Agent' to the Java-Part? Because i get this Error:
Java exception occurred:
java.io.IOException: Server returned HTTP response code: 403 for URL: https://finviz.com/screener.ashx?v=152&f=cap_smallover&ft=4&c=0,1,2,6,7,10,11,13,14,45,65
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
at java.net.URL.openStream(URL.java:1045)

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!