I'm trying to scrab data from a source website and organised the data. The source website page have some tabs , when I click different tabs, there would be different contents displayed. Now I'm using javascript to simulate this procedure. I'm not familiar with javascript, I'm getting stuck with the executing sequence of the code.
What I have tried:
here is my code:
var match=[];
var items=document.querySelectorAll('.date-list-swiper-slide');
for(let i of items) {
i.querySelector('.slide-item-wrap').click();
document.querySelectorAll('.item').forEach(function(item,i) {
var time=item.querySelector('.time-t').innerText;
var area_A=item.querySelector('.origin-area').innerText;
var area_B=item.querySelectorAll('.origin-area')[2].innerText;
var item={time:time,area_a:area_A,area_b:area_B};
match.push(item);
});
}
console.log(match);
The output just repeat the first tab-click content, and the webpage has switch ed to the last tab-click content.
It looks like the code
document.querySelectorAll('.item')
" DOES NOT wait the code
i.querySelector('.slide-item-wrap').click()
done and executed the following codes directlly.
What should I do to control following code after the click event has been done?