나는 다음과 같은 태그 분할하는 것을 시도하고있다 : 다음 코드를 사용하여파이썬 분할 문자열 인덱스
<h3><a href="#AC Adapter" onclick="getProductsBasedOnCategoryID('Asus','AC Adapter','ET1611PUT','6941', this, 'E Series')">AC Adapter
</a></h3>
을 그러나
print "FETCHING CATEGORY"
atag = s.h3
for data in atag:
while getattr(atag, 'name', None) != 'h3':
atag = atag.nextSibling
atag.a
atag = literal_eval('(' + atag.nextSibling.replace(', this', '').split('(', 1)[1])
print atag
을, 나는 다음과 같은 오류 얻을 :
을File "//CPSBS/RedirectedFolders/aysha/My Documents/asus_tables(edited) a tags.py", line 84, in <module>
atag = literal_eval('(' + atag.nextSibling.replace(', this', '').split('(', 1)[1])
IndexError: list index out of range
나는 뭔가 잘못하고있는 것으로 추측하고 있습니까? 또한이 a
태그는 onclick
속성을 가지고 있는데 대신 액세스하고 싶습니다. 그러면 다음 코드에 어떻게 입력합니까? 여기
http://www.asusparts.eu/partfinder/Asus/All에서 데이터를 분석하고있는 URL입니다
[편집]
탐색 트리 내가
에서 데이터를 검색하는 것을 시도하고있다<div id="accordion" class="ui-accordion ui-widget ui-helper-reset ui-accordion-icons" style="width: 760px;" role="tablist">
<h3 class="ui-accordion-header ui-helper-reset ui-state-active ui-corner-top" role="tab" aria-expanded="true" aria-selected="true" tabindex="0">
<span class="ui-icon ui-icon-triangle-1-s"></span>
<a onclick="getProductsBasedOnCategoryID('Asus','AC Adapter','ET10B','6941', this, 'E Series')" href="#AC Adapter" tabindex="-1" loaded="Loaded">AC Adapter </a>
</h3>
<div id="6941" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" role="tabpanel" style="display: block;">
<table class="productTableList">
<tbody>
</table>
<table class="productTableList">
<tbody>
<tr style="height:90px;background-color:#ebf4ff;">
<td class="ProduktLista" width="70px">
<td class="ProduktLista" width="315">
<a onclick="getProductInformationModal("Asus","14G110008340");">
<br>
코드를 실행할 수 있기 때문에 오류를 표시하는 대신, 해당 평가를 여러 개별 행으로 나누지 않고 무엇이 반환되는지 확인하십시오. ''분할' '. 처음 시도하면 도움이 될 것입니다. 또는 적어도 그 일을 한 후에 얻은 것을 게시하십시오. – CppLearner