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&toolid=10041&campid=5335899111&customid=SNJRD+834268-006&lgeo=1&mpre=http://www.ebay.com/sch/i.html?_nkw=834268-006&_ddo=1&_ipg=40&_os=PL%7CD&_pgn=1&_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&text=Jordan+Ultra+Fly+\u201cHyper+Turquoise\u201d&dates=20160415/20160415&details=http://sneakernews.com/2016/04/01/the-jordan-ultra-fly-hyper-turquoise-hits-stores-soon/&location=&sprop=website:http://sneakernews.com&pli=1&uid&sf=true&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&toolid=10041&campid=5335899111&customid=SNJRD+834268-011&lgeo=1&mpre=http://www.ebay.com/sch/i.html?_nkw=834268-011&_ddo=1&_ipg=40&_os=PL%7CD&_pgn=1&_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&text=Jordan+Ultra+Fly&dates=20160415/20160415&details=http://sneakernews.com/2016/03/16/jordan-ultra-fly-jimmy-butler-shoes/&location=&sprop=website:http://sneakernews.com&pli=1&uid&sf=true&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&toolid=10041&campid=5335899111&customid=SNJRD+834268-004&lgeo=1&mpre=http://www.ebay.com/sch/i.html?_nkw=834268-004&_ddo=1&_ipg=40&_os=PL%7CD&_pgn=1&_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&text=Jordan+Ultra+Fly&dates=20160415/20160415&details=http://sneakernews.com/2016/04/08/jordan-ultra-fly-black-infrared-release-date/&location=&sprop=website:http://sneakernews.com&pli=1&uid&sf=true&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.