I have a webpage that I am scraping for info. In the webpage everything I need is within separate divs with a specific class.
For example:
<div class="temp">text </div>
The issue is that there is different amounts of these divs each day, some days there are 5, then maybe 10 or 12. After the divs I need are more divs with the same class but have info I do not need. In the html there is a comment line separating the two. Like so:
<div class="temp">text </div>
<div class="temp">moretext </div>
<!-- beginning of historical data -->
<div class="temp">text </div>
I'm currently getting the divs with
var temps = window._document.getElementsByClassName('temp')
for (var I = 0; I < temps.length; i++){
var a = temps [i].getElementsByTagName('a')
var text = temps [i].textContent
//do something with vars }
That's working great, but since I don't know how many divs are before the comment I can't limit the for loop to just what I need and either pull everything, including what I don't need, if I set a limit I either pull too much or too little.
Is there a way to pull just the divs before the comment?