So This is my Python Code , After running this code when you reload the webdriver i face the error Access Denied You don't have permission to access site
I have also tried he Headless Method but that doesn't also work .
from time import sleep
import random
from selenium.webdriver.common.keys import Keys
import selenium
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.options import Options
class StockData:
def __init__(self):
# chrome_options = Options()
# chrome_options.add_argument('user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36')
# self.driver=webdriver.Chrome(executable_path=r'C:\Users\Arth\Desktop\codes\chromedriver.exe',chrome_options=chrome_options)
# agent = self.driver.execute_script("return navigator.userAgent")
options = Options()
options.headless = True
profile = webdriver.FirefoxProfile()
profile.set_preference("general.useragent.override", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36")
self.driver = webdriver.Firefox(profile,executable_path=r'C:\Users\Arth\Desktop\codes\geckodriver.exe')
def goSite(self):
driver=self.driver
driver.get("https://www.nseindia.com/market-data/volume-gainers-spurts")
sleep(3)
def start(self):
driver=self.driver
#driver.find_element_by_xpath("//img[contains(@title, 'Refresh') ]").click()
sleep(1)
names=driver.find_elements_by_xpath("//a[contains(@title, '_blank') ]")
print(names)
bot=StockData()
bot.goSite()
bot.start()```