我正在用python和selenium进行抓取。 尝试访问iframe中的表格。
页面源部分如下:
<div id="pageContentDiv">
<iframe frameborder="0" id="content" name="content" src="emxBlank.jsp" width="100%" height="100%"></iframe>
<iframe class="hidden-frame" id="hiddenFrame" name="hiddenFrame" src="emxBlank.jsp"></iframe>
<iframe class="hidden-frame" id="integrationsFrame" name="integrationsFrame" src="../integrations/emxIntegrations.jsp"></iframe>
<iframe class="hidden-frame" id="appletFrame" name="appletFrame" src="emxBlank.jsp"></iframe>
<iframe class="hidden-frame" id="ClipboardCollection" name="ClipboardCollection" src="emxClipboardCollection.jsp"></iframe>
</div>
在使用firefox检查器时,应该为
<div id="pageContentDiv" style="top: 0px;">
<div id="divPageHead" class="page-head">
<form method="post">
<div class="toolbar-subcontainer">
<table>
<tbody><tr>
<td class="page-title">
<h2>Part XXX XXXXXXXXX AA: BOM XXXXXXX</h2>
</td>
<td class="functions">
<table>
<tbody><tr>
<td class="progress-indicator"><div id="imgProgressDiv" style="visibility: hidden;"></div></td>
</tr></tbody></table>
</td>
</tr>
</tbody></table>
</div>
<script type="text/javascript">
function getTopAccessFrame() {
var oTop = this;
while(oTop && oTop.parent != oTop && oTop.name != "mxPortletContent" ){
try{
var doc = oTop.parent.test = "temp";
}catch(e){
break;
}
oTop = oTop.parent;}
try{
while(oTop.name != "mxPortletContent" && oTop.opener && oTop.opener.top){
var docOpenerTop = oTop.opener.top.test = "temp";
oTop = oTop.opener.top
}}catch(e){}
return oTop;}
</script>
<script type="text/javascript">
var topAccessFrame = getTopAccessFrame();
if(typeof topAccessFrame.emxUIConstants != "object"){
document.write("<scri" + "pt language=\"JavaScript\" type=\"text/javascript\" src=\"../common/emxUIConstantsJavaScriptInclude.jsp\"></scr" + "ipt>");
}else{
var emxUIConstants = topAccessFrame.emxUIConstants;
}
</script>
<script language="javascript" src="scripts/emxUICalendar.js"</script>
<script language="JavaScript" src="...></script>
<div class="toolbar-container" id="divToolbarContainer">
<div id="divToolbar" class="toolbar-frame"><div class="toolbar">
</div></div>
</div>
</form>
</div><!-- /#pageHeadDiv -->
<div id="divPageBody" style="top: 55px;">
<iframe name="portalDisplay" src="emxPortalDisplay.jsp?portal=ENCPartEBOMPortal&header=emxEngineeringCentral.ObjectPortal.PartEBOMHeader&HelpMarker=emxhelppartebompv&objectId=51758.28388.51328.17028&suiteKey=EngineeringCentral&StringResourceFileId=emxEngineeringCentralStringResource&SuiteDirectory=engineeringcentral&treeLabel=XXXX" border="0" width="100%" height="100%" frameborder="0"></iframe>
</div>
<div></div></div>
有关我的问题的详细信息:
我已经尝试过将iframe切换为
iframe=driver.find_element_by_name("ClipboardCollection")
driver.switch_to.frame(iframe)
不能解决我的问题。