我正在关注此tutorial。但是我被困在这里:
for container in containers:
date = container.find('td', class_ = 'date-action').get_text()
date = parser.parse(date.strip()[6:]).date()
dateli.append(date) #make date relevant to current date
description_container_1 = container.find('td', class_ = 'description TL_NPI_TransDesc')
description_container_2 = description_container_1.find('a', class_ = 'transactionTitle')
description = description_container_2.find('span', class_ = 'transTitleForEditDesc').get_text()
descli.append(description)
amount = container.find('td', class_ = ['amount positive TL_NPI_Amt', 'amount TL_NPI_Amt isDebit']).get_text()
amtli.append(float(price_str(amount)))
我的问题是如何用'div“ [id * =” wtDataMov“]'替换('td',class_ ='date-action'),因为这是识别我要获取的行的唯一方法是大ID LT_BPINetEmpresas_wt37_block_wtMainContent_CW_Contas_Empresas_wtMovimentos_block_wtMovimentosList2_ctl04_wtDataMov
的特定部分。
答案 0 :(得分:0)
要使用CSS选择器,请使用.select()
。如果您只找到第一个标签,请使用 <html>
<head>
<title>Your site title</title>
</head>
<body>
<script>
( function() {
var insertAdsByGoogleJs = function() {
var element = document.createElement('script');
var firstScript = document.getElementsByTagName('script')[0];
var url = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
element.async = true;
element.type = 'text/javascript';
element.src = url;
firstScript.parentNode.insertBefore(element, firstScript);
};
// Run this in an interval (every 0.1s) just in case we are still waiting for consent
var cnt = 0;
var consentSetInterval = setInterval(function(){
cnt += 1;
// Bail if we have not gotten a consent response after 60 seconds.
if( cnt === 600 )
clearInterval(consentSetInterval);
if( typeof window.__tcfapi !== 'undefined' ) { // Check if window.__tcfapi has been set
clearInterval( consentSetInterval );
window.__tcfapi( 'addEventListener', 2, function( tcData,listenerSuccess ) {
if ( listenerSuccess ) {
if( tcData.eventStatus === 'tcloaded' || tcData.eventStatus === 'useractioncomplete' ) {
if ( ! tcData.gdprApplies ) {
// GDPR DOES NOT APPLY
// Insert adsbygoogle.js onto the page.
insertAdsByGoogleJs();
}
else {
// GDPR DOES APPLY
// Purpose 1 refers to the storage and/or access of information on a device.
var hasDeviceStorageAndAccessConsent = tcData.purpose.consents[1] || false;
// Google Requires Consent for Purpose 1
if (hasDeviceStorageAndAccessConsent) {
// GLOBAL VENDOR LIST - https://iabeurope.eu/vendor-list-tcf-v2-0/
// CHECK FOR GOOGLE ADVERTISING PRODUCTS CONSENT. (IAB Vendor ID 755)
var hasGoogleAdvertisingProductsConsent = tcData.vendor.consents[755] || false;
// Check if the user gave Google Advertising Products consent (iab vendor 755)
if(hasGoogleAdvertisingProductsConsent) {
// Insert adsbygoogle.js onto the page.
insertAdsByGoogleJs();
}
}
}
}
}
} );
}
cnt++;
}, 100);
})();
</script>
<!-- One test unit for GDPR -->
<ins class="adsbygoogle"
style="display:inline-block;width:970px;height:250px"
data-ad-client="ca-pubxxx"
data-ad-slot="slot_id">
</ins>
<!-- Another test unit for GDPR -->
<ins class="adsbygoogle"
style="display:inline-block;width:250px;height:250px"
data-ad-client="ca-pubxxx"
data-ad-slot="slot_id">
</ins>
<script>
// This will trigger the ad request if ads were unpaused in the CMP consent check above.
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</body>
</html>
.select_one()