Closed medknecth closed 3 years ago
According to the rules of the new website, using scripts to scrape data is not allowed and they've enforced this by blocking scripts from accessing the site. They've also changed the way the values are calculated. So the new version is a work-in-progress but it might take a while.
Thats Great, But I got your code to late, by the time nse is changing lay out. If I can be of any help please do let meknow.
Once I'm done, I'll update the code and close this issue so you'll know.
Sir, I succeeded in getting data from new website and made the final df as in your code from my code. Now if I am doing modification in your code, getting stucked. Major change is won only tail left. If you allow I can share my code and with your small time our new code logic should be up. Thanks
You can share the code file here itself so we can test it.
Can you please drag and drop the .py file here.
Upload it is as a .txt file as .py file can't be uploaded I'm assuming
Upload it is as a .txt file as .py file can't be uploaded I'm assuming
Yes it was not allowed. Uploaded Txt File
Thanks for the code I'm working on an improved version.
Great sir, I understand performance wise my code is not much stable but I believe as per new nse sites cookies authentication is must, and nseappid cookie can be used from code. I will be waiting for your time and modifying current code.
On Tue, 1 Sep 2020, 19:51 Varun Shanbhag, notifications@github.com wrote:
Thanks for the code I'm working on an improved version.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/VarunS2002/Python-NSE-Option-Chain-Analyzer/issues/1#issuecomment-684891323, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXNQSFIYVG5LAW7R5FS3U3SDT7PZANCNFSM4QO43EGA .
Great sir, I understand performance wise my code is not much stable but I believe as per new nse sites cookies authentication is must, and nseappid cookie can be used from code. I will be waiting for your time and modifying current code. … On Tue, 1 Sep 2020, 19:51 Varun Shanbhag, @.***> wrote: Thanks for the code I'm working on an improved version. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#1 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXNQSFIYVG5LAW7R5FS3U3SDT7PZANCNFSM4QO43EGA .
Since your using the json data instead of scraping I tried this :
import requests, json
headers = {'user-agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/84.0.4147.89 Safari/537.36"}
res = requests.get("https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY", headers=headers)
with open("data.json", "w") as f:
json.dump(res.json(), f)
I didn't have to create a cookie to do this. Although the function you wrote to convert the json data to a dataframe is very useful.
3.0_oop.txt Use this for the time being. Note that this is set to NIFTY and 3 Sep 2020. I'm working on restructuring the code and adding support for other indexes and expiry dates.
Good Evening Sir, got delayed with office work. You code I tested today it was not so smooth as earlier one reason data from new website. It gave error two times after 15minutes or so ....else stop responding. But data was matching in real time. I tried to replicate same code by changing API url but it did not worked...am I missing some thing here.
The website was having issues today even the normal page for option chain wasn't loading properly. I guess this is why the old website is still live and working so the old program (2.0) works just fine. The new version
The new version is ready and is in testing. I'm ironing out the last bugs I can find. Will release it in a day or two.
Thanks Senior. Also canI have personal email id to ask you some thing on market.
Thanks Senior. Also canI have personal email id to ask you some thing on market.
Oh no I do not know anything about the market you know more since you're using this program😅. I'm just an IT guy who did this for my boss who gave me the conditions and requirements.
Same here I too an IT guy, but learned python because of NSE....so that I can see this code works. But with interest in market I got deeply involved and exploring more of python.
That's nice
I've committed the new version to the master branch. See if you can find any issues so I'll fix them and then draft a release
Sir,
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\A967\Anaconda3\lib\tkinter__init.py", line 1705, in call
return self.func(*args)
File "C:\Users\A967\Anaconda3\lib\tkinter\init.py", line 749, in callit
func(*args)
File "
After 20 minutes same error, I think data is not available in continuous fashion from new website. Else the older one with old site works perfect as always.
Did the program crash because of this or did this just show up in the console?
It shows up in the console, program just go silent and data stops updating.
I updated the code it should now ignore that error. I earlier added except condition for json decode but apparently anaconda is using a different package for that.
I have published the new release and updated the documentation. Link to the release. If you face any problems feel free to open a new issue👍. Also thanks for the help in the json to dataframe function.
Varun, could you please help in modyfying the code to work with nse new website.