0
   <div class="el-table-box" v-if="!specialAnnounce">
                        <el-table ref="notice-table" v-loading="loading" :data="dataList" @sort-change="sortChange">
                            <template slot="empty">
                                <div class="loading" v-if="dataList.length == 0 && loading">
                                    加载中...
                                </div>
                                <div v-if="dataList.length == 0 && !loading" class="no-data">
                                    <img src="http://static.cninfo.com.cn/new/img/announce/no-data.png" alt="">
                                    <p>暂无数据!</p>
                                </div>
                            </template>

                            <el-table-column width="100" prop="secCode" sortable="custom" label="代码">
                                <template slot-scope="scope">
                                    <a class="ahover" target="_blank" :href="'/new'+ '/disclosure/stock?stockCode=' + scope.row.secCode + '&orgId=' + scope.row.orgId">
                                        <span class="code">{{scope.row.secCode}}</span>
                                    </a>
                                </template>
                            </el-table-column>
                            <el-table-column width="180" prop="secName" label="简称">
                                <template slot-scope="scope">
                                    <a class="ahover" target="_blank" :href="'/new'+ '/disclosure/stock?stockCode=' + scope.row.secCode + '&orgId=' + scope.row.orgId">
                                        <span :title="scope.row.secName" class="code delete-hl" v-html="scope.row.secName.length>8?scope.row.secName.slice(0,8)+'...':scope.row.secName"></span>
                                    </a>
                                </template>
                            </el-table-column>
                            <el-table-column prop="announcementTitle" label="公告标题">
                                <template slot-scope="scope">
                                <span class="ahover">
                                    <a v-html="scope.row.announcementTitle" target="_blank" :href="linkLastPage(scope.row)"></a>
                                    <span v-show="checkDocType(scope.row.adjunctType)" class="icon-f"><i class="iconfont" :class="[checkDocType(scope.row.adjunctType)]"></i></span>
                                </span>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" align="left" prop="announcementTime" sortable="custom" label="公告时间">
                                <template slot-scope="scope">
                                    <span class="date">{{fomatDate(scope.row.announcementTime, 'yyyy-MM-dd HH:mm')}}</span>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>

How can I read this entire table with entries which are published within the latest 2 hours?

Steven
  • 24,410
  • 42
  • 108
  • 130

2 Answers2

0

You just have to wait until the element you want becomes visible, after processing the JavaScript, see below <template>.

wait = WebDriverWait(driver, 10)
time_element = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'span.date')))

7.39. Expected conditions Support

Сергей Кох
  • 1,417
  • 12
  • 6
  • 13
0

To locate the element <span class="date"> you need to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "el-table-column[prop='announcementTime'][label='公告时间'] > template[slot-scope='scope'] > span.date")))
    
  • Using XPATH:

    element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//el-table-column[@prop='announcementTime' and @label='公告时间']/template[@slot-scope='scope']/span[@class='date']")))
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352