2

So basically. I have 2 classes. One is date of shoe release. Another is shoes released in that date. However they're entirely two different classes. So I am trying to scrape from these classes. "month header" which has all the dates. And the next class which is sneaker-post-main has all the shoes from the date in month header. However they're two different classes. They're not linked to each other. So I tried doing .nextSibling from h4 class to catch my 'section' class. It didn't work like that.

<h4 class="month-header">April 15, 2016</h4>
<section class = "sneaker-post-main">...</section>
<section class = "sneaker-post-main">...</section>
<section class = "sneaker-post-main">...</section>
<h4 class="month-header">April 16, 2016</h4>
<section class = "sneaker-post-main">...</section>
<section class = "sneaker-post-main">...</section>
<section class = "sneaker-post-main">...</section>
<h4 class="month-header">April 17, 2016</h4>
<section class = "sneaker-post-main">...</section>
<section class = "sneaker-post-main">...</section>
<section class = "sneaker-post-main">...</section>

Also if my HTML makes no sense this is the website I'm scraping from. http://sneakernews.com/air-jordan-release-dates/ I wanted output to look like Date to be the key of a dictionary and the value to be list of shoes that is going to be released in that date. Like shown below.

April 16 2015
{
    Shoe info 1
    Shoe info 2
    Shoe info 3
}
April 17 2015
{
    Shoe info 1
    Shoe info 2
    Shoe info 3
}

I'm trying to do this task using BeautifulSoup. I can't seem to figure it out. April 15, 2016 -> This is release date HTML. ... -> This contains shoes information etectra.(Like there are list of shoes not just one shoes in there)

from bs4 import BeautifulSoup
import requests
import json


headers = {
    #'Cookie': 'X-Mapping-fjhppofk=FF3085BC452778AD1F6476C56E952C7A; _gat=1; __qca=P0-293756458-1459822661767; _gat_cToolbarTracker=1; _ga=GA1.2.610207006.1459822661',
    'Accept-Encoding': 'gzip, deflate, sdch',
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36,(KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36',
    'Accept-Language': 'en-US,en;q=0.8',
    'Accept': '*/*',
    'Connection': 'keep-alive',
    'Content-Length': 0
}
response = requests.get('http://sneakernews.com/air-jordan-release-dates/',headers=headers).text
soup = BeautifulSoup(response)
for tag in soup.findAll('h4', attrs = {'class':'month-header'}): 
    print tag.nextSibling.nextSibling.nextSibling

This is my code so far!

Benji
  • 137
  • 3
  • 15

2 Answers2

1

You can use the find_next_siblings() method and a simple slice operation return those sections immediately after the h4 tag.

Demo using sample HTML document:

In [32]: from bs4 import BeautifulSoup 

In [33]: result = []

In [34]: html = """<h4 class="month-header">April 15, 2016</h4>
   ....: <section class = "sneaker-post-main">...</section>
   ....: <section class = "sneaker-post-main">...</section>
   ....: <section class = "sneaker-post-main">...</section>
   ....: <h4 class="month-header">April 16, 2016</h4>
   ....: <section class = "sneaker-post-main">...</section>
   ....: <section class = "sneaker-post-main">...</section>
   ....: <section class = "sneaker-post-main">...</section>
   ....: <h4 class="month-header">April 17, 2016</h4>
   ....: <section class = "sneaker-post-main">...</section>
   ....: <section class = "sneaker-post-main">...</section>
   ....: <section class = "sneaker-post-main">...</section>"""

In [35]: soup = BeautifulSoup(html, 'html.parser')

In [36]: for header in soup.find_all('h4', class_='month-header'):
   ....:     d = {}
   ....:     d['month'] = header.get_text()
   ....:     d['released'] = [s.get_text() for s in header.find_next_siblings('section', class_='sneaker-post-main')[:3]]
   ....:     result.append(d)
   ....:     

In [37]: result
Out[37]: 
[{'month': 'April 15, 2016', 'released': ['...', '...', '...']},
 {'month': 'April 16, 2016', 'released': ['...', '...', '...']},
 {'month': 'April 17, 2016', 'released': ['...', '...', '...']}]

UPDATE:

If the number of "section" in not constant then you do it like this (probably not efficient) using a generator function.

def gen(soup): 
    for header in soup.find_all('h4', class_='month-header'):
        d = {}
        d['month'] = header.get_text()
        d['released'] = []
        for s in header.find_next_siblings('section', class_='sneaker-post-main'):
            nxt =  s.find_next_sibling()
            if isinstance(nxt, Tag) and nxt.name != 'h4':
                d['released'].append(s)
            else:
                d['released'].append(s)
                break
        yield d

The generator function takes one argument which is a "soup".

from bs4 import BeautifulSoup, SoupStrainer, Tag

wanted_tag = SoupStrainer(['h4', 'section']) # only parse h4 and section tags 
soup = BeautifulSoup(response, 'html.parser', parse_only = wanted_tag)

for tag in soup(['script', 'style', 'img']):
    tag.decompose() #  Just to clean up little bit

for d in gen(soup):
    # do something
styvane
  • 59,869
  • 19
  • 150
  • 156
  • Hey dude. I tried that solution. It came out funky. So basically I want is key-value. Dates{ Shoes releases } Here is what I tried. arr = [] for d in gen(soup): key = d['released'] for items in key: d['released'] = items.text.split('\n') arr.append(d) with open('shoes_released.json','wb') as outfile: json.dump(arr,outfile,indent=4) – Benji Apr 14 '16 at 00:06
  • Does this [answer](http://stackoverflow.com/a/36546480/3100115) give you the expected result? – styvane Apr 14 '16 at 05:15
1

Reverse the logic, get all the section.sneaker-post-main then find each ones previous sibling using that as the key to group in a dict:

import  requests
from collections import defaultdict


cont = requests.get(url, headers=ua).content

soup = BeautifulSoup(cont,"lxml")

d = defaultdict(list)
sections = soup.select("div.release-post-list  section.sneaker-post-main")
for section in sections:
    h4 = section.find_previous_sibling("h4",{"class":"month-header"})
    d[h4.text.strip()].append(section)

print(d["April 15, 2016"])

Using the first header text as the key, you can see you get the correct first three sneaker-post-main:

[<section class="sneaker-post-main">\n<div class="sneaker-small-post">\n<div class="small-post-data">\n<div class="release-img">\n<img alt="" src="https://s3.amazonaws.com/images.kicksfinder.com/products/thumbs/d0500aee543dc81a4b192bcf906621d4_1459874417.jpg"/><p class="relea-ebay"><a href="http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&amp;toolid=10041&amp;campid=5335899111&amp;customid=SNJRD+834268-006&amp;lgeo=1&amp;mpre=http://www.ebay.com/sch/i.html?_nkw=834268-006&amp;_ddo=1&amp;_ipg=40&amp;_os=PL%7CD&amp;_pgn=1&amp;_sop=1" target="_blank"> Buy now on EBAY</a></p> </div>\n<div class="release-right">\n<div class="post-header">\n<h2 class="header-title">\n<a href="http://sneakernews.com/2016/04/01/the-jordan-ultra-fly-hyper-turquoise-hits-stores-soon/"><span>Jordan Ultra Fly \u201cHyper Turquoise\u201d</span></a> </h2>\n<div class="date-and-name">\n<p class="release-price"><span><sup>$</sup>\n<em>125</em></span></p>\n<div class="release-rating">\n<i class="moible-rating-votes">(55)</i><div class="post-ratings" data-nonce="2f8edf6e7b" id="post-ratings-644786"><span class="default-rating-digit release-first-rating-digit"><span class="show-rating-digit default-rating-digit">2.74</span> /  5 <i>(55 VOTES)</i></span><div class="vote-icon"><span class="rating-img"> <i><b><span class="post-ratings-text" id="ratings_644786_text"></span></b></i> <img alt="RATE THIS" id="rating_644786_1" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 1, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on_left.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_644786_2" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 2, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_644786_3" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 3, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on_left.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_644786_4" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 4, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_644786_5" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 5, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on_left.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_644786_6" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 6, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off_right.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_644786_7" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 7, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_644786_8" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 8, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off_right.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_644786_9" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 9, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_644786_10" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(5.47, 5, 0);" onmouseover="current_rating(644786, 10, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off_right.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/></span>\xa0</div></div><div class="post-ratings-loading" id="post-ratings-644786-loading">\n<img alt="Loading..." class="post-ratings-image" height="16" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/loading.gif" title="Loading..." width="16"/>Loading...</div></div>\n</div>\n</div>\n<div class="post-data">\n<div class="release-text">\n<p>Size Run: Mens</p>\n<p>Color: Black/Reflect Silver-Hyper Turquoise </p>\n<p>Style Code: 834268-006</p>\n</div>\n<div class="release-post-bot">\n<div class="release-icon">\n<strong>Add to Your:</strong>\n<span class="add-left">\n<a href="https://www.google.com/calendar/render?action=TEMPLATE&amp;text=Jordan+Ultra+Fly+\u201cHyper+Turquoise\u201d&amp;dates=20160415/20160415&amp;details=http://sneakernews.com/2016/04/01/the-jordan-ultra-fly-hyper-turquoise-hits-stores-soon/&amp;location=&amp;sprop=website:http://sneakernews.com&amp;pli=1&amp;uid&amp;sf=true&amp;output=xml#eventpage_6" target="_blank">Google calendar</a>\n<a class="ical_button" data-post_id="644786" href="/release-dates/?ical=1">Ical</a>\n<!-- <a class="ical_button" href="/wp-content/themes/sneakernews/ical-page.php">Ical</a>-->\n</span>\n</div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</section>, <section class="sneaker-post-main">\n<div class="sneaker-small-post">\n<div class="small-post-data">\n<div class="release-img">\n<img alt="" src="https://s3.amazonaws.com/images.kicksfinder.com/products/thumbs/890b7a6892bd86fcae650df7905a1f61_1458672661.jpg"/><p class="relea-ebay"><a href="http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&amp;toolid=10041&amp;campid=5335899111&amp;customid=SNJRD+834268-011&amp;lgeo=1&amp;mpre=http://www.ebay.com/sch/i.html?_nkw=834268-011&amp;_ddo=1&amp;_ipg=40&amp;_os=PL%7CD&amp;_pgn=1&amp;_sop=1" target="_blank"> Buy now on EBAY</a></p> </div>\n<div class="release-right">\n<div class="post-header">\n<h2 class="header-title">\n<a href="http://sneakernews.com/2016/03/16/jordan-ultra-fly-jimmy-butler-shoes/"><span>Jordan Ultra Fly</span></a> </h2>\n<div class="date-and-name">\n<p class="release-price"><span><sup>$</sup>\n<em>125</em></span></p>\n<div class="release-rating">\n<i class="moible-rating-votes">(290)</i><div class="post-ratings" data-nonce="de124c5bbc" id="post-ratings-641202"><span class="default-rating-digit release-first-rating-digit"><span class="show-rating-digit default-rating-digit">2.24</span> /  5 <i>(290 VOTES)</i></span><div class="vote-icon"><span class="rating-img"> <i><b><span class="post-ratings-text" id="ratings_641202_text"></span></b></i> <img alt="RATE THIS" id="rating_641202_1" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 1, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on_left.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_641202_2" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 2, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_641202_3" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 3, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on_left.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_641202_4" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 4, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_641202_5" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 5, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_641202_6" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 6, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off_right.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_641202_7" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 7, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_641202_8" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 8, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off_right.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_641202_9" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 9, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_641202_10" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.49, 4, 0);" onmouseover="current_rating(641202, 10, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off_right.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/></span>\xa0</div></div><div class="post-ratings-loading" id="post-ratings-641202-loading">\n<img alt="Loading..." class="post-ratings-image" height="16" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/loading.gif" title="Loading..." width="16"/>Loading...</div></div>\n</div>\n</div>\n<div class="post-data">\n<div class="release-text">\n<p>Size Run: Mens</p>\n<p>Color: Black/Reflect Silver-White</p>\n<p>Style Code: 834268-011</p>\n</div>\n<div class="release-post-bot">\n<div class="release-icon">\n<strong>Add to Your:</strong>\n<span class="add-left">\n<a href="https://www.google.com/calendar/render?action=TEMPLATE&amp;text=Jordan+Ultra+Fly&amp;dates=20160415/20160415&amp;details=http://sneakernews.com/2016/03/16/jordan-ultra-fly-jimmy-butler-shoes/&amp;location=&amp;sprop=website:http://sneakernews.com&amp;pli=1&amp;uid&amp;sf=true&amp;output=xml#eventpage_6" target="_blank">Google calendar</a>\n<a class="ical_button" data-post_id="641202" href="/release-dates/?ical=1">Ical</a>\n<!-- <a class="ical_button" href="/wp-content/themes/sneakernews/ical-page.php">Ical</a>-->\n</span>\n</div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</section>, <section class="sneaker-post-main">\n<div class="sneaker-small-post">\n<div class="small-post-data">\n<div class="release-img">\n<img alt="" src="https://s3.amazonaws.com/images.kicksfinder.com/products/thumbs/072c8db9c92e8307d6a6f87848c8cd66_1460135541.jpg"/><p class="relea-ebay"><a href="http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&amp;toolid=10041&amp;campid=5335899111&amp;customid=SNJRD+834268-004&amp;lgeo=1&amp;mpre=http://www.ebay.com/sch/i.html?_nkw=834268-004&amp;_ddo=1&amp;_ipg=40&amp;_os=PL%7CD&amp;_pgn=1&amp;_sop=1" target="_blank"> Buy now on EBAY</a></p> </div>\n<div class="release-right">\n<div class="post-header">\n<h2 class="header-title">\n<a href="http://sneakernews.com/2016/04/08/jordan-ultra-fly-black-infrared-release-date/"><span>Jordan Ultra Fly</span></a> </h2>\n<div class="date-and-name">\n<p class="release-price"><span><sup>$</sup>\n<em>125</em></span></p>\n<div class="release-rating">\n<i class="moible-rating-votes">(17)</i><div class="post-ratings" data-nonce="c90fa37887" id="post-ratings-645454"><span class="default-rating-digit release-first-rating-digit"><span class="show-rating-digit default-rating-digit">2.47</span> /  5 <i>(17 VOTES)</i></span><div class="vote-icon"><span class="rating-img"> <i><b><span class="post-ratings-text" id="ratings_645454_text"></span></b></i> <img alt="RATE THIS" id="rating_645454_1" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 1, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on_left.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_645454_2" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 2, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_645454_3" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 3, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on_left.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_645454_4" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 4, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_645454_5" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 5, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_on_left.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_645454_6" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 6, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off_right.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_645454_7" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 7, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_645454_8" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 8, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off_right.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_645454_9" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 9, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/><img alt="RATE THIS" id="rating_645454_10" onclick="rate_post();" onkeypress="rate_post();" onmouseout="ratings_off(4.94, 5, 0);" onmouseover="current_rating(645454, 10, 'RATE THIS');" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/stars/rating_off_right.png" style="cursor: pointer; border: 0px;" title="RATE THIS"/></span>\xa0</div></div><div class="post-ratings-loading" id="post-ratings-645454-loading">\n<img alt="Loading..." class="post-ratings-image" height="16" src="http://cdn.sneakernews.com/wp-content/plugins/wp-postratings/images/loading.gif" title="Loading..." width="16"/>Loading...</div></div>\n</div>\n</div>\n<div class="post-data">\n<div class="release-text">\n<p>Size Run: Mens</p>\n<p>Color: Black/Reflective Silver-White</p>\n<p>Style Code: 834268-004</p>\n</div>\n<div class="release-post-bot">\n<div class="release-icon">\n<strong>Add to Your:</strong>\n<span class="add-left">\n<a href="https://www.google.com/calendar/render?action=TEMPLATE&amp;text=Jordan+Ultra+Fly&amp;dates=20160415/20160415&amp;details=http://sneakernews.com/2016/04/08/jordan-ultra-fly-black-infrared-release-date/&amp;location=&amp;sprop=website:http://sneakernews.com&amp;pli=1&amp;uid&amp;sf=true&amp;output=xml#eventpage_6" target="_blank">Google calendar</a>\n<a class="ical_button" data-post_id="645454" href="/release-dates/?ical=1">Ical</a>\n<!-- <a class="ical_button" href="/wp-content/themes/sneakernews/ical-page.php">Ical</a>-->\n</span>\n</div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</section>]

Each h4.month-header can have lots of section.sneaker-post-main siblings but each section.sneaker-post-main only has one previous h4.month-header sibling relating to its section.

Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321