VBA - Download data from NSE website

Novaleet

New Member
Joined
Jan 2, 2017
Messages
3
****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
down votefavorite
I've created some VBA code that downloads what the NSE (National Stock Exchange of India) website calls "BhavCopy". However, it appears they have changed the code on their website which now prevents my code from working.
The RAW URL is https://www.nseindia.com/products/content/equities/equities/archieve_eq.htm If you choose a date (say today) and then select BHAVCOPY report, the site will provide you with a link to download the csv.zip file.
However, if you click on the link directly (https://www.nseindia.com/content/historical/EQUITIES/2017/JAN/cm02JAN2017bhav.csv.zip), the URL returns an error:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">Access Denied

You don
't have permission to access "http://www.nseindia.com/content/historical/EQUITIES/2017/JAN/cm02JAN2017bhav.csv.zip" on this server.
Reference
#18.11367a5c.1483362327.35d38c1b</code>Would anyone be kind enough to help me understand why this is happening and how I can get around it? All I'm trying to do is access the csv.zip files for any date.
Many thanks in advance



<tbody style="margin: 0px; padding: 0px; border: 0px;">
</tbody>
</body>Hi All

I've created some VBA code that downloads what the NSE (National Stock Exchange of India) website calls "BhavCopy". However, it appears they have changed the code on their website which now prevents my code from working.


The RAW URL is https://www.nseindia.com/products/content/equities/equities/archieve_eq.htm If you choose a date (say today) and then select BHAVCOPY report, the site will provide you with a link to download the csv.zip file.


However, if you click on the link directly (https://www.nseindia.com/content/historical/EQUITIES/2017/JAN/cm02JAN2017bhav.csv.zip), the URL returns an error:


Access Denied


You don't have permission to access "http://www.nseindia.com/content/historical/EQUITIES/2017/JAN/cm02JAN2017bhav.csv.zip" on this server.
Reference #18.11367a5c.1483362327.35d38c1b



I have not attached any VBA code as I believe the issue is not VBA related but rather to do with the website (I am happy to share the code if that helps). If anyone be kind enough to help me understand why this is happening and how I can get around it? All I'm trying to do is access the csv.zip files for any date.


Many thanks in advance
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Sorry - I'm not sure what happened above. Must be some text I copied. Here is the question again:

Hi All

I've created some VBA code that downloads what the NSE (National Stock Exchange of India) website calls "BhavCopy". However, it appears they have changed the code on their website which now prevents my code from working.

The RAW URL is https://www.nseindia.com/products/content/equities/equities/archieve_eq.htm If you choose a date (say today) and then select BHAVCOPY report, the site will provide you with a link to download the csv.zip file.

However, if you click on the link directly (https://www.nseindia.com/content/historical/EQUITIES/2017/JAN/cm02JAN2017bhav.csv.zip), the URL returns an error:

Code:
Access Denied

You don't have permission to access "http://www.nseindia.com/content/historical/EQUITIES/2017/JAN/cm02JAN2017bhav.csv.zip" on this server.
Reference #18.11367a5c.1483362327.35d38c1b

I have not attached any VBA code as I believe the issue is not VBA related but rather to do with the website (I am happy to share the code if that helps). If anyone be kind enough to help me understand why this is happening and how I can get around it? All I'm trying to do is access the csv.zip files for any date.

Many thanks in advance
 
Upvote 0
Hi,

I also faced the same problem with the EOD down-loader I have created. After a bit of tweaking today with chrome I noticed that if cookies are allowed for this NSE Site then it wont download.

So open the nse site. Go to settings and block cookies for this site and everything shall work fine.

Regards,

Pash
 
Upvote 0
Yes but how does that affect downloading using Excel VBA? How would you block Excel from accepting cookies?
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,923
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top