i need to scrape 7 main news from this website - tengrinews.kz, the date, time and title of each news. I use selenium and installed firefox developer edition.
I inspected the website and the 7 news are located in this structure:
<body>
<header> ... some stuff </header>
<main>
<div class="tn-main-news-grid">
<div class="tn-main-news-item firs-column tn-three-column tn-background-cover">
<span class="tn-main-news-title" style="z-index: 1;">BIG MAJOR NEWS TEXT</span>
<a href="/kazakhstan_news/major-news/" class="tn-link"><span class="tn-hidden">BIG MAJOR NEWS TEXT</span></a>
</div>
<div class="tn-main-news-item">
<span class="tn-main-news-title">news1 TEXT</span>
<a href="/kazakhstan_news/news1/" class="tn-link">
<span class="tn-hidden">news1 TEXT</span></a>
</div>
<div class="tn-main-news-item">
<span class="tn-main-news-title">news2 TEXT</span>
<a href="/kazakhstan_news/news2/" class="tn-link">
<span class="tn-hidden">news2 TEXT</span></a>
</div>
<div class="tn-main-news-item">
<span class="tn-main-news-title">news3 TEXT</span>
<a href="/kazakhstan_news/news3/" class="tn-link">
<span class="tn-hidden">news3 TEXT</span></a>
</div>
</div>
</main>
</body>
I located the div frame that contains all 7 news by xpath or css_selector . I do get firefox web element, but it's a list and it's empty!
If i try locating single href or div it gives back some web element of type 'list' and this href must have text attribute(according to selenium docs) - but it gives me error "no attribute text"
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://tengrinews.kz")
css_to_big_news = 'html body div.my-app main section.tn-main-section.tn-container div.tn-main-news-container.tn-sub-container div.tn-main-news-grid div.tn-main-news-item.firs-column.tn-three-column.tn-background-cover a.tn-link'
href_big = driver.find_elements_by_css_selector(css_to_big_news)
print('type of href_big is %s and length is %d' %(type(href_big), len(href_big)))
print(href_big[0].text) #this is wrong
print(href_big.text()) # this is wrong with parenthesis
what's wrong?