如何使用Selenium / PhantomJS从JavaScript代码标记中获取数据

时间:2017-07-14 15:26:22

标签: javascript java html selenium phantomjs

我希望从网页上获取信息。当我在浏览器中检查页面源时,我得到简单的HTML标签,即

<h3 class="Sans-17px-black-85%-semibold">my_title</h3>

然而,当我运行PhantomJS时,我想要的信息以某种方式存储在由图像包围的CSS(?)中,即(来自driver.getPageSource())

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" style="display: none" class="datalet-bpr-guid-572130">
    <code style="display: none" id="bpr-guid-572131">
{ /* many lines of code here ... */ {"$deletedFields":["courses","projects","description","recommendations","honors","entityLocale","organizations","region"],"locationName":"my_city,my_state","entityUrn":"urn:li:fs_position:(ACoAACJOkiYB8DxCiFxrW3EEdFpeIjMlZ2S84ck,997784449)","companyName":"my_company_name","timePeriod":"urn:li:fs_position:(ACoAACJOkiYB8DxCiFxrW3EEdFpeIjMlZ2S84ck,997784449),timePeriod","company":"urn:li:fs_position:(ACoAACJOkiYB8DxCiFxrW3EEdFpeIjMlZ2S84ck,997784449),company","title":"my_title","companyUrn":"urn:li:fs_miniCompany:5163810","$type":"com.linkedin.voyager.identity.profile.Position"} /* more lines of code */
    </code></img>

有没有办法让<code>成为像浏览器这样的HTML标签和/或从<code>内部获取我想要的数据?

0 个答案:

没有答案