我正在尝试从政府网页获取数据,但是,当我获取页面源时,它不包含浏览器中显示的数据。
from selenium import webdriver
from selenium.webdriver.support.ui import Select
page = 'http://web.cvm.gov.br/app/esforcosrestritos/#/consultarOferta'
driver = webdriver.Chrome()
driver.get(page)
## Click on "Encerrada"
driver.find_element_by_xpath('//*[@id="content"]/div[4]/div[2]/div/div /div[4]/div[2]/label[3]/input').click()
## Select year
year = Select(driver.find_element_by_xpath('//*[@id="content"]/div[4]/div[2]/div/div/div[4]/div[1]/div/select'))
year.select_by_visible_text('2017')
## Click on "Pesquisar"
driver.find_element_by_xpath('//*[@id="content"]/div[4]/div[3]/div/a[1]/span').click()
## Click on "DEBENTURES SIMPLES" inside "Ofertas Encerradas"
driver.find_element_by_css_selector('#content > div.container.ng-scope > div:nth-child(4) > div:nth-child(2) > div > table > tbody > tr:nth-child(15) > td.col-lg-2.text-left.ng-binding').click()
## Click on 1st result
driver.find_element_by_css_selector('#content > div.container.ng-scope > div:nth-child(4) > div > div > table > tbody > tr.text-center > td.text-left.ng-binding').click()
##Page Source
html = driver.page_source
在这个例子中,第一个字段“CNPJ”,而不是得到值“04.031.960/00001-70”,我得到这个:
<input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-valid-maxlength" data-ng-cnpj="" data-ng-model="$responsavel.ofertante.cnpj" data-ng-change="getNomeResponsavelPorCnpj($responsavel.ofertante)" data-ng-disabled="mesmosDadosEmissor || $responsavel.disabled" maxlength="18" disabled="disabled">
此外,如果我将鼠标悬停在浏览器中的值上,则无法选择它。
有没有办法从这种类型的页面获取数据?