pythonseleniumweb-scrapingautosuggestakamai

Dynamic dropdown doesn't populate with auto suggestions on https://www.nseindia.com/ when values are passed using Selenium and Python


driver = webdriver.Chrome('C:/Workspace/Development/chromedriver.exe')
driver.get('https://www.nseindia.com/companies-listing/corporate-filings-actions')
inputbox = driver.find_element_by_xpath('/html/body/div[7]/div[1]/div/section/div/div/div/div/div/div[1]/div[1]/div[1]/div/span/input[2]')
inputbox.send_keys("Reliance")

I'm trying to scrape the table from this website that would appear after you key in the company name in the textfield above it. The attached code block works well with such similar drop-downs of a normal google search and wolfram website, but when i run my script on the required website, that essentially just inputs the required text in the textfield - the dropdown shows 'No Records Found', whereas, when done manually it works well.


Solution

  • I executed your test adding a few tweaks and ran the test as follows:

    nseindia


    Deep Dive

    It seems the click() on the element with text as Get Data does happens. But while inspecting the DOM Tree of the webpage you will find that some of the <script> tag refers to JavaScripts having keyword akam. As an example:

    Which is a clear indication that the website is protected by Bot Manager an advanced bot detection service provided by Akamai and the response gets blocked.


    Bot Manager

    As per the article Bot Manager - Foundations:

    akamai_detection


    Conclusion

    So it can be concluded that the request for the data is detected as being performed by Selenium driven WebDriver instance and the response is blocked.


    References

    A couple of documentations:


    tl; dr

    A couple of relevant discussions: