I am trying to parse certain span tags from Winmo profiles (e.g., like https://open.winmo.com/open/decision_makers/ca/pasadena/jorge/garcia/489325) which do not have id or class values, i.e.,
<span itemprop="email">j****@***********.com</span>
<div itemscope="" itemprop="address" itemtype="http://schema.org/PostalAddress">
<span itemprop="streetAddress">177 East West Colorado Boulevard</span>
<span itemprop="addressLocality">Pasadena</span>,
<span itemprop="addressRegion">CA</span>
<span itemprop="postalCode">91195</span>
<span itemprop="addressCountry">USA</span>
I found two old StackOverflow examples helpful (this and this), but I am still getting null values for each of the 9 span itemprop-matching lines on the webpage with the following code:
var nodes=[], values=[];
var els = document.getElementsByTagName('span'), i = 0, whatev;
for(i; i < els.length; i++) {
prop = els[i].getAttribute('itemprop');
if(prop) {
whatev = els[i];
nodes.push(whatev.nodeName); // provides attribute names, in all CAPS = "SPAN"
values.push(whatev.nodeValue); // for attribute values, why saying null if els[i] is fine?
console.log(values); // (whatev) outputs whole thing, but it seems values is what I need
// break; // need this? seems to prevent values after first span from generating
}
}
How do I return just the partly-hidden email value (j****@***********.com) and the postalCode (91195) from these kinds of pages? I need the solution in plain JS because I will be compressing it into a bookmarklet for others.