这是运行javascript的html代码的一部分。我正在尝试访问此脚本的文本。当我执行“检查元素”时,可以看到所需的文本。但是,当我去查看页面源代码或driver.page_source时,它不存在-仅存在此javascript。是否有办法以某种方式运行此javascript,以便我可以抓取它在网页上显示的文本?
以下是在page_source中未显示的Inspect Element代码。我正在尝试访问粗体文本:
<table id="invoiceHistoryTable" class="display dataTable no-footer" cellspacing="0" width="100%" role="grid" aria-describedby="invoiceHistoryTable_info">
<tbody>
<tr role="row" class="odd">
<td class="sorting_1">**4/11/2019 04:12:43 PM**</td><td>291321</td><td>- -</td><td>**Invoice uploaded from file=93564LedesInvoiceAnsi.txt.**</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1">**4/11/2019 04:19:57 PM**</td><td>291321</td><td>- -</td><td>**Client retrieved invoice for processing.**</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1">**4/17/2019 04:05:19 PM**</td><td>291321</td><td>- -</td><td>**Invoice approved.**</td></tr>
</tbody>
<thead>
<tr role="row"><th id="header0" class="sorting_asc" tabindex="0" aria-controls="invoiceHistoryTable" rowspan="1" colspan="1" data-column-index="0" aria-label="Date: activate to sort column descending" aria-sort="ascending">Date</th><th id="header1" class="sorting_disabled" rowspan="1" colspan="1" data-column-index="1" aria-label="Invoice No">Invoice No</th><th id="header2" class="sorting_disabled" rowspan="1" colspan="1" data-column-index="2" aria-label="User">User</th><th id="header3" class="sorting_disabled" rowspan="1" colspan="1" data-column-index="3" aria-label="Description">Description</th></tr>
</thead></table>
这是page_source和javascript代码:
<div class="roundedBoxContent">
<table id="invoiceHistoryTable" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th id="header0">Date</th>
<th id="header1">Invoice No</th>
<th id="header2">User</th>
<th id="header3">Description</th>
</tr>
</thead>
</table>
</div>
<script type="text/javascript">
jQuery(function() {
setupDatePicker("dateStart", "dateEnd");
});
setCurrentPageSizeInDropdown();
var parameters= {"vendorId" : "379863141", "uniqueId" : "6cebf4f4340ccb1f9efcfafab51e28ea", "role" : "6",
"buttonText" : {
"defaultViewButtonText" : "Default View",
"doneButtonText" : "Done"
},
"clearButton" : {
"buttonId" : "clear",
"formId" : "searchForm",
"filtersClass" : "filters",
"tableId" : "invoiceHistoryTable"
},"tooltips" : {
"showHideTooltip" : "Show/Hide Columns",
"exportExcelTooltip" : "Export to Excel",
"exportPdfTooltip" : "Export to PDF",
"printTooltip" : "Print",
"viewEditTooltip" : "",
"viewTooltip" : ""
}
};
jQuery(".chosen-select").chosen({
width: "20%"
});
invoiceHistoryTable.loadVendorLevelTable(parameters);
</script>