Reputation: 55
I have a list of 500 indices. I am trying to just pull the corresponding name of the company for each index. I am using a simply request for each item:
url = 'https://www.nasdaq.com/markey-activity/stocks/{}'.format('CCL')
r = requests.get(url)
This request keeps running and doesn't return anything.
I also tried a simple `curl {url}' which doesn't return anything in terminal either.
Is this something specific with NASDAQ?
Upvotes: 0
Views: 1279
Reputation: 25196
Could reproduce the problem and also run into an "endless" loading. Do not know why, but you may try the following:
Scraping Website
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'C:\Program Files\ChromeDriver\chromedriver.exe')
URL = 'https://www.nasdaq.com/market-activity/stocks/tsla'
driver.get(URL)
driver.implicitly_wait(3)
name = driver.find_element_by_css_selector('span.symbol-page-header__name').text
print(name)
driver.close()
"Scraping API"
from selenium import webdriver
import json
driver = webdriver.Chrome(executable_path=r'C:\Program Files\ChromeDriver\chromedriver.exe')
URL = 'https://api.nasdaq.com/api/company/tsla/company-profile'
driver.get(URL)
jsonResponse = json.loads(driver.find_element_by_tag_name('pre').text)
print(jsonResponse['data'].get('CompanyName'))
driver.close()
Direct use of API
https://dataondemand.nasdaq.com/docs/?python#
Upvotes: 1