# If you want indices also then replace rows[6:] with just rows fno = [row.find('a').text for row in rows[6:] if row.find('a').text in row.find('a').get('href')]
On BeautifulSoup, It is a very messy process time enhancer. I literally skip it at every possible way possible. Most work anyways get done because Pandas have table selector frame and String Strips.
1. Yes, pd.read_html is pretty simple, personally I would avoid BeautifulSoup unless absolutely necessary 2. I detailed BeautifulSoup approach in context to your first code
Also, blocking my NSE is not basis headers value
I don't use BeautfilSoup in any of my trading code
No No, I meant NSE blocks scrapping to their server sometimes. (Happens randomly; I am not talking about IP Block which they do if you fetch within 3 minutes multiple time..)
I tried to tweak with the headers value in the request module. But all in vain. NSEPY, NSETOOLS. Nothing works that time. Maybe cookie; I will keep looking.
@Amit Ghosh Here's the code in case you want to use it. You'd need to download chromedriver and pass it's path to the code .... also set your download directory.
from time import sleep from selenium import webdriver import os
@tahseen those two files have not just the name but also all the other details you'd need for fno contracts (both options and futures). How you'd download it and how you'd parse it is upto you
Anyway, why don't you just use Instrument file that Zerodha provides everyday in the morning ? It has it all. If you have a Zerodha Kite account
So failsafe.
Here is what I use on that - tables will contain the FNO data.
1. Yes, pd.read_html is pretty simple, personally I would avoid BeautifulSoup unless absolutely necessary
2. I detailed BeautifulSoup approach in context to your first code
Also, blocking my NSE is not basis headers value
I don't use BeautfilSoup in any of my trading code
I tried to tweak with the headers value in the request module. But all in vain. NSEPY, NSETOOLS. Nothing works that time. Maybe cookie; I will keep looking.
https://www.nseindia.com/content/fo/sos_scheme.xls
https://www.nseindia.com/content/fo/fo_mktlots.csv
I use selenium to download these two using python.
requests and pandas will do the magic