Python Looping and Web Scraping | BeautifulSoup - python

Currently trying to loop the following web scraping...
My current problem is that I can only get the first footballer from the table (I have the table HTML down below) and not the full 10 players, my immediate thoughts are that the loop isn't working and I'm unsure where I'm going wrong. I'm using the BeautifulSoup Method of gathering the data.
TD;DR My error is that only 1 player is appearing in my CSV file instead of the 10 players available from the HTML
Python Code
from urllib.request import urlopen as uReq
from urllib.request import Request
from bs4 import BeautifulSoup as soup
my_url = "https://www.fctables.com/teams/stoke-194901/"
#opening up connection , grabbing page
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
#html parsing
page_soup = soup(page_html, "html.parser")
topScorers = page_soup.findAll("table",{"class":"table table-striped table-bordered table-hover stage-table table-condensed top_scores"})
filename = "stokeGoals.csv"
f = open(filename, "w")
headers = "player, goal_scored, average_goal"
f.write(headers)
for topScorer in topScorers:
#top 10 players who scored
player = topScorer.a["title"]
#top 10 goalscorers for the team
goalpp = topScorer.findAll("div", {"class": "progress"})
#average goal per game
avg = topScorer.findAll("div", {"class": "label label-primary"})
avgpp = avg[0].text.strip()
print("player: " + player)
print("goal_scored: " + goalpp)
print("AVG: "+ avgpp)
f.write(player + "," +goalpp.replace("," , "|")+ "," + avgpp +"\n")
f.close()
HTML Code for the table/website I'm scraping data from
<table class="table table-striped table-bordered table-hover stage-table table-condensed top_scores">
<thead>
<tr>
<th>#</th>
<th class="tl">Player</th>
<th data-toggle="tooltip" title="Goals scores by player / Goals scores by his team">goals</th>
<th data-toggle="tooltip" title="Average goals">
Avg
</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td class="tl psh" data-id="212996">
<img alt="Benik Afobe" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/s4/s4glg58a2350823d58/benik-afobe.png" width="20" /> Afobe
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 100%;">
<span class="goal_p">6</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.4</div>
</td>
</tr>
<tr>
<td>2</td>
<td class="tl psh" data-id="320050">
<img alt="Thomas Ince" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/t5/t5ni157c703a92110b/thomas-ince.jpg" width="20" /> Ince
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 83.333333333333%;">
<span class="goal_p">5</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.6</div>
</td>
</tr>
<tr>
<td>3</td>
<td class="tl psh" data-id="308648">
<img alt="Saido Berahino" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/po/poyhu58a234e0da106/saido-berahino.png" width="20" /> Berahino
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 66.666666666667%;">
<span class="goal_p">4</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.3</div>
</td>
</tr>
<tr>
<td>4</td>
<td class="tl psh" data-id="257340">
<img alt="Joe Allen" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/6w/6w45558a234deae78e/joe-allen.png" width="20" /> Allen
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 50%;">
<span class="goal_p">3</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.4</div>
</td>
</tr>
<tr>
<td>5</td>
<td class="tl psh" data-id="234407">
<img alt="Erik Pieters" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/et/et08558a234dd63b68/erik-pieters.png" width="20" /> Pieters
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 50%;">
<span class="goal_p">3</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.4</div>
</td>
</tr>
<tr>
<td>6</td>
<td class="tl psh" data-id="299368">
<img alt="Peter Crouch" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/qp/qptn558a234df86f1f/peter-crouch.png" width="20" /> Crouch
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 33.333333333333%;">
<span class="goal_p">2</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.3</div>
</td>
</tr>
<tr>
<td>7</td>
<td class="tl psh" data-id="214479">
<img alt="Bojan Krkic" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/pl/pleyv57eaedf0afeac/bojan-krkic.jpg" width="20" /> Krkic
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 33.333333333333%;">
<span class="goal_p">2</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.4</div>
</td>
</tr>
<tr>
<td>8</td>
<td class="tl psh" data-id="253114">
<img alt="James McClean" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/gb/gbjmm58a234f55a560/james-mcclean.png" width="20" /> McClean
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 16.666666666667%;">
<span class="goal_p">1</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.1</div>
</td>
</tr>
<tr>
<td>9</td>
<td class="tl psh" data-id="309022">
<img alt="Sam Clucas" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/g7/g7dig58a234cb144a3/sam-clucas.png" width="20" /> Clucas
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 16.666666666667%;">
<span class="goal_p">1</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.3</div>
</td>
</tr>
<tr>
<td>10</td>
<td class="tl psh" data-id="215724">
<img alt="Bruno Martins Indi" class="img-circle" height="20" src="https://static.fctables.com/upload/images/20x20/hk/hkung58a234de0dfaa/bruno-martins-indi.png" width="20" /> Indi
<div class="slider">
<div class="inner"></div>
</div>
</td>
<td width="30%">
<div class="progress">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="55" class="progress-bar progress-bar-primary" role="progressbar" style="width: 16.666666666667%;">
<span class="goal_p">1</span>
</div>
</div>
</td>
<td>
<div class="label label-primary">0.2</div>
</td>
</tr>
</tbody>

The webpage you specified, loads data via XMLHttpRequest
You can grab the html directly from:
https://www.fctables.com/xml/table_participant/?template_id=&season_id=52%2C38%2C88&type_home=overall&type=top_score&lang_id=2&team_id=194901&limit=10
Through the above url, you can get all the information you need without the extra html noise, i.e.:
my_url = "https://www.fctables.com/xml/table_participant/?template_id=&season_id=52%2C38%2C88&type_home=overall&type=top_score&lang_id=2&team_id=194901&limit=10"
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")
_names = page_soup.findAll("img",{"class":"img-circle"})
_goals = page_soup.findAll("span",{"class":"goal_p"})
_avg = page_soup.findAll("div",{"class":"label label-primary"})
x = 0
for name in _names:
name = name['alt']
avg = _avg[x].get_text()
goals = _goals[x].get_text()
print(name, avg, goals)
x+=1
Benik Afobe 0.4 6
Thomas Ince 0.6 5
Saido Berahino 0.3 4
Joe Allen 0.4 3
Erik Pieters 0.4 3
Peter Crouch 0.3 2
Bojan Krkic 0.4 2
James McClean 0.1 1
Sam Clucas 0.3 1
Bruno Martins Indi 0.2 1
Note:
Adjust the url values as needed, you can change top_score, type, team_id, limit, etc...

Keeping the url as it is, you can try the following to fetch the required results:
import requests
from bs4 import BeautifulSoup
url = "https://www.fctables.com/teams/stoke-194901/"
res = requests.get(url)
soup = BeautifulSoup(res.text,"html.parser")
for items in soup.select(".top_scores tbody tr"):
name = items.select_one("td a[href^='/players/']").get("title")
goal = items.select_one("td .goal_p").text
avrg = items.select_one("td .label-primary").text
print(name, goal, avrg)
Output you should get:
Benik Afobe 6 0.4
Thomas Ince 5 0.6
Saido Berahino 4 0.3
Joe Allen 3 0.4
Erik Pieters 3 0.4
Peter Crouch 2 0.3
Bojan Krkic 2 0.4
James McClean 1 0.1
Sam Clucas 1 0.3
Bruno Martins Indi 1 0.2

Related

BeautifulSoup, How can i pull out all instances not in tags

I really didn't want to write but i am stuck!
How can i extract from this page all instances of just this part:
<a href="https://www.uplay.it/gioco-da-tavolo-Azul.html">
49,90 €
I tried this one but the name and price aren't in that tag.
wishlist = soup.find_all(class_="tooltip")
Many many thanks in advance
<tr onMouseOver="this.style.backgroundColor = '#E1EAFE'" onMouseOut="this.style.backgroundColor = 'transparent'">
<td class="tooltip" id="21010" width="180">
<div class="wishlist-img-frame">
<a href="https://www.uplay.it/gioco-da-tavolo-Azul.html">
<img class="wishlist-img" src="thumb_Azul.jpg" alt="Azul" title="Azul" id="img_Azul" data-pagespeed-url-hash="2469707013" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/></a>
</div>
<br>
<small>Azul </small>
</td>
<td class="">
2-4
</td>
<td class="" width="60">
<a href="https://www.uplay.it/gioco-da-tavolo-Azul.html"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAtCAMAAAANxBKoAAAABGdBTUEAALGPC/xhBQAAAmdQTFRFTGlxAgICAAAAAAAAAAAAAgEBBAQDCwoKERERBAMCB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Z5XVafXmBwulxzicpg0+qNFdBbMAQfCSN1+2ByinZ5XVFmin9egzOtLCov5FBwnq4n7IBPnqB42FJe/VlhY+Hp5cV5OLsL40IyMfTyTy0Ie34AnB2zWM5jgMDsH97ABJTcXtxxiDMaB/wYqjUn4LAqRLNyy9+N/AK3h/QOI7P6IAAAAAElFTkSuQmCC" title="Tedesco
" data-pagespeed-url-hash="3016993694" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/></a>
</td>
<td class="" width="60">
<a href="https://www.uplay.it/gioco-da-tavolo-Azul.html"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAEx0lEQVQ4y7WU32tcRRTHv2fu3Ls/krQmTVLbtEmT/ohRSKVoWwpFQaylaEX0wQcf9aEPFYr/gCg+KRYEUV/FBwsKgiJ9aKvYYLEUapq2aX62+dEku9vdvdm9u3funTtzfNhNQqEVXxwYzsAcPt85h+8ZevXUGfwfSz7ugq2F54rU9va2XofpWQL1AwiM4LFSoXC7WE98N5M1IPpvYDYGgZ/PVFF6vWdgx/uvHT1+uLO9gzLZFgBAWK+hcH+xeuHsl+duJckXYnDolkil7ePBzCjMzVIma/tkT/azFw6//OaLw4dwqHcYEg6YeC0Ne/sH2oa89LsTV66+9fvYzY9ub+n6yngp9UhwbnaSonq+zxvqP3fsleMHW1vbUFEBhBAQJECCAAYYAHQCXamhv3/giS3dXZ/an3/tmujd9WHiuvEaTwBAbmaCcuOjrand7We3Dw0crBqF+XoBflKD67pwXRdSupCuCyklhOMAfgVJLo9UXTkHe3eeyVy/9gabZL3hYnlqnG6P/OZsHd5zclQtnKy6BotRCbnQRzEOAEFwHAeOI5rbgSMI1i+Dy2WYfAFtKk7vK5Y/7iLuXAdP/TVCKS/VVut2TuvOFjGWm8GiKmGpXkIhqoIBEAEEggBBEAGWYUs+TL4IflCCnrmLDmP3hiMjJ9iaBjhSkXxq/9N9U2HuENISi2ERNwqzmKvlkQ/9Rk9Ba/RGZAYXfdilFdTGJ8HFEjZJFztr9bdNGEoAEMay63N0QDsWLAVYChR1FfdWl1EIymAwQARaE2h6vL68ArWwCKpUIQF4RGhLzP6VqTsuAAjLVvr16h64DiCarwIhISAyGmDGxgg0z8zgWMNpaEJQo0WSqKs4PyuZLaS11nWEiMBrXmqadeOB/764mcYAMyJVrQIMCCISrW7mLsUGZBiw2BB4NOehswVgmKGZEYLvhUoZbvqYivMrk23Gq8FYwFjA2nUCA2DmRwoweB2qrMEy2yuJtQnAEMxsHyzlVzdX+AJqESgyQNwQYNMc42adzBvRMkOzhWILZS38ROs7Wn3vep4hEASBDBsT6xn/WzdfqyKMQbEBtAWYYa2F1gl0YpAYiyRJYK2BZovIWoTWopxoTOjo/M3V8t9eymMAECRIM6ALd5emtxa9b6gQWNQ1ECawYYw4ihGpCLGKEEURIhUhUgqhTVC1Br7RWNDx7OUw+ERZU+vYtZtJCEjXcXRsWZnEqPy12R+edAc6chS8Yzoynt6sUPbLyAoPjuMAQKMC38dqFKGSaMzpePanaumD6aAymfZc09mzkwFACiESEhTCciqqh07pz5mvO/dtm17da08lbmXH8sJ9avHSkNIFACSJhnpQxHwYxLfC4NJFHX4+X129IaUTbereatp7ehvfZsf2HlNevh+FURwQQCpUiMfmzmfmsleDQXFkZMsfx7Z1bxvMpNPtzBxXguri+Ojo9UvL879MFgvXtbUlxxFBynPjXcMHrBCNyujEe6dx9cfvRL1el2EUt4C5lYEMEXmCSEoppRBCAiQAZsusE61DY21IRHVHiCCd8lTvM8Nm4Lkj676UQkoMHn3JTly+mACoqVgnsByBOW2YPRPHTtPv6/NAgCKi0BGOas2m42xHp+nb//xDZv8Hx9zYG9nc3fIAAAAASUVORK5CYII=" title="Italiano
" data-pagespeed-url-hash="2763445148" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/></a>
<a href="https://www.uplay.it/gioco-da-tavolo-Azul.html"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAEnElEQVQ4y7WVbUxbVRjH7z33tre9bSmsUCgvFtgubAXEtryzwningAPMVBbmlDEG6N7IJpmwLdbFzLgZHNB9MGoEjdESJwHH4pKpMYYJmyaDkbGMMaYmM2oyPgiic318zm0hAYO6D3745Tw5z//53+ecnHMuU9HcwvwfrJ5s2s8UbW/grI5N4RmFxSXxKRn18amZz9hy84rTSspDy3btJQ9mjIaldU18enZ2ekxMZI8kSXeysrK8TqcTKA6HwxsXF3fbFGV2pxSXJzobdpN/NkbDgm31jCUlPTA7O7ujsrJy7vWODvB4PNDf37+Mvr4+6O7uhpqarbPmddLBkromcRXj/Yw1v4QxGAxBdrvd09raCm63Gzo7O1elq6tL1rhcLnDkbTxVUteo/psxNTWFhalsNltXdXW1t729Hdra2v4TVFtbW3vfGB5xwNmwZ2lbmDTnZkan1XI5jpxSUa3+vbqqCurqdjwQT9bUgCAId7MrKi1LxqGRUUStUuny7PZPHyLEu0mSoL64ECmS2bkK9UsUgtOywWvmiPfh8Ah38fZdcteMKIqKdEmyHNZp59/iCAwolDBqNsN4cjKMWa0wjkw8glj9YHwVR5obQ80IageVSngbaw+Jmu8qcnJDZWOO49TlCYnbXiUcDLAMDCNjLAuTggDTej3MhBhhJswEM6ZwHzQ2GuEm5qjmCmppzSdIB3o8brUV0cOAxkSfFRBwqBMF5xgGRpGryHXkhp+bHAfTvA8aT6H2hl8zgYwg53DOjeQJqh3ljftkY0OWTtfehV886zem4km/6RQyvYIpf27S38Si8WmkQNTU2wudsrGxdP36xg5C5OXQZY3/i/GiOdWMUWP/VtBVO9YEVSRkOliG57mwtHgp/0VRXPAQFr7A5CWC5hhfw3ESub4COnfNr/kWx8+xhta6OP7HtcGGWNmYdqxVqRJf3po0MtQswHi7Gr4/LsLPr4lw95QIs10aRFyBRs5RzQ/H1TB2WA1DzwrQstHwvhYvw6KxgWVZqaxA2veOS3H/Yg+BW4MEfvmMhblhFhZGCPxxicCfl1m4hyOFzs0N+zS3BlmgNb3H+N+sFl0+XhQFvXTyqSCERGtEwXawPursmRMELr/LwjQW/HSBgdkvGfj1Kwbm8SMUGtM5mqOab95jof8kgYYnQk8rFXyQFm+xfCoUPK9G8zDsOj7SpC84+lzEyEcnWPi6B/f4DAu3h1i4c95nRKExnaM5qvn4JAstTwUO6HXKdTx64U1my/GlZDR48/xdm9E8MTI8sPB57Lz3mPLeeTctJnDlAxYm+ogMjUd7WaA51Cw0bQnu0QcoE9AjUL7FZVW+tyIiOpbgl1Q8x4UwDBOLJGo1QkZepunAkeaQi28eFeY/fMXXGcWD8RtHlHMv7Ay+YEvQP61UcBJHiEElCKqwKDNb1rjXZ5y1eQuD+0IUCl7Eo2fErmMQCyFssqDkUqOj9M7cVMOegkztS4jLkbJmd1S4rpjnSRKuMgafhBC6BVqNhqSXVS5/jzMqHpPNeXm/OQMWRKD5WmQDXQGS5CeBztEcaiLpiVo0TS19dNkf5C/4utIc4GifogAAAABJRU5ErkJggg==" title="Tedesco
" data-pagespeed-url-hash="3016993694" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/></a>
</td>
<td class="">
<img src="https://www.uplay.it/stock_1_1.png" alt="Disponibilità: Immediata (poche copie)" title="Disponibilità: Immediata (poche copie)" data-pagespeed-url-hash="3301201864" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/>
</td>
<td class="">
<a href="https://www.uplay.it/gioco-da-tavolo-Azul.html">
49,90 €
</a>
</td>
<td style="">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACsAAAAoCAMAAABQF/NcAAAABGdBTUEAALGPC/xhBQAAAv1QTFRF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Zo3R9+WB8FSFSa7mchLY0RHxFZ0n/v0C+LtsUCFgJ3BY323SqDxtTroyOLH2GocdKYiI77yJHD1RUXH3KHJQIYhkc3LbE4OVHjZ/IAGq1apTqexoQcQq+Z+tmkMVFfs0RwYVomh26umaMFXANNtPSKlPPHdaDXXXr5Lf2y/v7JTvH1RECKLjvspK1NuWNSWWGLlZ20dkeTwgl0eIQK3lGiWeo7/NGctVIJ9OZQtEYAPr10cIItXbQFUtn/HSw+PxONR03yQj99zZATWEFgGC6Mi4gfrzXGOS73QUDhSLiXPAYrGoWcuSGFzJN6e2parjEhLi1KkD9bUNXAZj2SwUFuuAw5lkPA6LdSQ4kQiz32ckJXMl53/8uf7ixfqzm7MauEYG44PZBJIbwRFskHEmk4IhkomuC5R6RjKXq2q4dKlBxeUmM/TKBTR7oj2GRHUHGYVywLo7UezJXq7Ozs7zFy1h6BmMZCAJFksWzUej0TQvIshQGY+CsiQMEVQ7lzEuY+YuXLxCKVGpJMoVixfOHePiYueMppHtKU7uJtcBO+KaZGDmvKXvAEvnzTQ9veq6u5lkGhpsOzsXKGXGvHB2Rrt6kSEwdAfN4UGmkkzNkb1oNFdXV/QIsKR5eZGhNYoTwRwXZRqvozsMjULBYOwtEImWOwaDoZBIVDCx5vlabJgx/IBAoFLd3NycALhRqfDC3dHRshXg/gfM3O2qPZwwAAAAAABJRU5ErkJggg==" data-nome="Azul" style="margin-right:5px; cursor:pointer;" onclick="update_cart('21010');" id="Azul" class="basket" data-pagespeed-url-hash="2966354299" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/>
</td>
</tr>
<tr>
<td height="0" class=" wishlist-row--border" colspan="10" < tr>
<tr onMouseOver="this.style.backgroundColor = '#E1EAFE'" onMouseOut="this.style.backgroundColor = 'transparent'">
<td class="tooltip" id="2264" width="180">
<div class="wishlist-img-frame">
<a href="https://www.uplay.it/gioco-da-tavolo-Balloon-Cup.html">
<img class="wishlist-img" src="thumb_Balloon_Cup.jpg" alt="Balloon Cup" title="Balloon Cup" id="img_Balloon_Cup" data-pagespeed-url-hash="536172911" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/></a>
</div>
<br>
<small>Balloon Cup </small>
</td>
<td class="">
2
</td>
<td class="" width="60">
<a href="https://www.uplay.it/gioco-da-tavolo-Balloon-Cup.html"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAtCAMAAAANxBKoAAAABGdBTUEAALGPC/xhBQAAAvpQTFRFTGlxAgICAAAAAAAAAAAAAwMDAAAABAQFBAQFAAAAAAAAAAAAAAAAAAAAAAAACQgIAQEBAAAAbhcjPEFYLS0wWw4ZKjNMEh0+KDBMKywzSExXSUZMFiFJCxQ5kYmJh3+Do5qdZgQTdkVLgIOUlI+PhIGJbzo/YwwXalNWkImLlXJ3ZGyBayAqVxggLTZOf25woaKkOT5OkoiJZWyEaSoygXR+k5GSsKyqt6ipBxA3Z22Ai2JlbR8qbCYwWC0xP0hThmlvgnFxCQ4xiIOFdk9UfH1/bT9D0RMr////zhMqzxQr0BMpyRMozBQq1C1A/f//xBIovxIn+Pn5xgwinBIjARpd+/z90xIrxRMqlgwcuRsv7e3r15qiqhAjhgkZ89vfrg0iAg09//797r7E8MfN9vHyjpq3AB5u/vX5zhkvjgwdsxEl8szS3eHrprDEARVZogsfsxgrBB5lcQ4a4YeTeQ4cuBEm45ynARRSvEhVoxAgh5W1ABdjfI2z47O51jpM3VxrylxqlDM/vBEm//j4vhcr6OjouQoh4+fu9fT2lqDA4sDEy9DSozpGRFiL2UVX2lBg32Z1yBQt4X2J89LV5JGe5KewfIepAhNKwQwi5NvcqrbO4uDgtUJQn6vF4ba9rKytnJyexFJg6K+4c3+iuYyS/PL28+PmaXijgo+rzqWr0LzAwmRwgiYx8fHxxWd0jImOqH6EA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4vvcwPAIk/ORcVzt7Co5BD3OT50cbzi0YuJ/y7sIJIAvnTLGnWFjhmPAPNnBQxgp6eAMeBoNiQbIi4phq/uJpr+dE6CkMQ6C1JNJfwwZOpkNvRSJZgJAAtcQHv1Tjb8NuPiDwWJB7AAAAAElFTkSuQmCC" title="Inglese
" data-pagespeed-url-hash="3505320999" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/></a>
</td>
<td class="" width="60">
<a href="https://www.uplay.it/gioco-da-tavolo-Balloon-Cup.html"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAFeklEQVQ4y7XTWWycVxnG8f853zffLJ4Zjz1eZDuxE2eP3bhplCZSIGna5oIqAURAYiuCK5SbSgEEElwgKBJSERJcICS2G6BFYukWVNKiyk0r0i0RwVmcxJ14iR074/HYs3/LOS8XDkUIVeKGc3WkI/3e5+jVo46fOs3/47gf9CAiuqctk8s0KgdKE1dHlB+lraMabVs2FTPDw28VSuWpSGzwv8EihGGgPPH6p6/OPHHfw4cef3RsZ59Nt9OWSmHCEDPQy6Sb8sdfnTzXN5R7yutIvBZaE34gHIUBCzev67tTsw/d/+BjP/3C41/cfuzIGJvciGoqixYQEWJbBhnuGYg76cFj517/25HS4uxPYt2Jb1sl1f+Cg1aTt888q7Pp7kf2H/7U744+fLgTUfiBAcdil0ooARELvd2YvKHZarJv3/1eodBz+tq1d9qzG9qeCIypvw8HrSZvvfgntXf3ri0nPv7pX+T7d3QW5taoB0IriFCeYIrFe7AgzRYGzdKyDxj2jg5xX87/0t35qcl3Rf8wstYCuDfffVO1qmveoW07vzE61DO4+8B2PhQq3ningEZQvg9Ly1gBsRZTq+Eoy2BvkgODHSSnrnHp5b+o25Xy1zYeO/rsrXJlCsCpLBfdPSOjW/e4yR91Z7Lx/pGddHXmGBsdYqCvk3Bunsorr0G9ganWcYYHGTi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VVTSjWzXT3BwRMnxfW8dfj4qdMsTRe4cPaMK2I9pVQSkaQVSQAxwFlvE7De6hAItdYNEWkqpfxsV0948MRJ+y8U4J843dS8w6BlNAAAAABJRU5ErkJggg==" title="Inglese
" data-pagespeed-url-hash="3505320999" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/></a>
<a href="https://www.uplay.it/gioco-da-tavolo-Balloon-Cup.html"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAFr0lEQVQ4y7WUS2xcZxmG3+8/58zNM5n6MjOmztjJ2Cbjqo6J0xTbSd1LaCAlooSkVZEqIcGqqJt0Azs2FStYlKKigli1FFoINzVc0kYJEbk1MSGZtL5MPL6O5+qZ4zkzc67//7MItRBSJDZ820969Op93++jYy+dwv9j1PstpBDw+VR/7IFgXxDqfkjsBtCUhEylVJyt2aKuBUMcRP8bWHCOtl4JOYrx1b5U38vHDz49Ge/pRiAYAhGh3Wqhms8bZ157472s7fyIpUc+Zv4Avz9YSpRXFikQFP3+VOcPxz/3+InpfROY3DkKRgxSShARJCQGB1ORtD/wrflLV587f+fOq590x18XPr/1n2DlswcmAQDFxXmSTq0fw9HfHjn6pcPxWAwKEdLxXfAcF6f/cA7LqxsYTiWhCYnGx/OI7tjhH3zwwaeKM//g9UjkimTKtnIGAIXsLJXmbofVVPQH/WN7xg3PxJpZhe40oaoqLl6+hQtznfjjVY5P5nJgigrRaIAXSwhYjjKVTH43dPPGccG9bcNZITuL3I0rSmws9exNY/lEU/WQd3QUzS1suk0QIzRbLjR/GKo/CsslKIwBug5Zq4OXSoiYVmBPtf5qTPLYNnjx+mXmV9Ww2aO+7PSE6HZ5EXmrhpJZR8VqQPxXKAQAQsDb1MGrNXibNTjZHLq4HGpfunRUCv5vK6RUhkdHBu6apUcR8iHfrmFlOY/GegO1duM+XZSwGwaWDBPlpTVA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yv0DH9Gxl05hM7+K2+f+MiqFeNjzvHMuF89DimtSyjoABURpAoWlFDnGlCkpxRkiKgd8PgtEh0Kd3eXB/Z/f0ouFx1P79r+tKKr3L+B08fJe7KBdAAAAAElFTkSuQmCC" title="Italiano Scaricabile Online
" data-pagespeed-url-hash="2558428881" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/></a>
</td>
<td class="">
<img src="https://www.uplay.it/stock_7.png" alt="Disponibilità: Prodotto Fuori Catalogo O In Fase Di Ristampa" title="Disponibilità: Prodotto Fuori Catalogo O In Fase Di Ristampa" data-pagespeed-url-hash="2464760904" data-pagespeed-onload="pagespeed.CriticalImages.checkImageForCriticality(this);" onload="var elem=this;if (this==window) elem=document.body;elem.setAttribute('data-pagespeed-loaded', 1)"/>
</td>
<td class="">
<a href="https://www.uplay.it/gioco-da-tavolo-Balloon-Cup.html">
17,80 €
</a>
</td>
<td style="">
</td>
</tr>
<tr>
'''
Try something along these lines:
from bs4 import BeautifulSoup as bs
play = """your html above"""
for a in soup.select('td> a[href]'):
target = a.text.strip()
if len(target)>0 and '€' in target:
print(a['href'],a.text.strip())
Output:
https://www.uplay.it/gioco-da-tavolo-Azul.html 49,90 €
https://www.uplay.it/gioco-da-tavolo-Balloon-Cup.html 17,80 €
Edit:
To write to a csv file for importation to Excel try:
with open('play.csv', mode='w') as play_file:
play_writer = csv.writer(play_file, delimiter=',')
for a in soup.select('td> a[href]'):
entry = []
target = a.text.strip()
if len(target)>0 and '€' in target:
entry.extend([a['href'],a.text.strip()])
play_writer.writerow(entry)
Many thanks again. I alredy did it this way and seems to work.
Now i have to polish the cells value!
wishlist = []
for a in soup.select('td> a[href]'):
target = a.text.strip()
titolo = target
if len(target)>0 and '€' in target:
#print(a['href'],a.text.strip())
price = a['href'],a.text.strip()
wishlist.append([price, titolo])
df = pd.DataFrame(data=wishlist, columns=['Titolo', 'Prezzo'])
df.to_excel(r'wishlist.xlsx', index = False, header=True)

how to get values from nested tables using beautifulsoup

I need to get the name and the price of each row in the sample html below, however when I'm using beatifulsoup to find_all('tr') it returns all the tr of the main table and the nested tables. what is the best way for extracting only the value and the price of each row?
soup = BeautifulSoup(f, 'html.parser')
priceTable = soup.find('table', attrs={"class":"table table-hover table-responsive"})
Above is what I have and it returns "all" the tr including the nested tables.
What I need is to get all the names and the price of each item in front of it, and finally save them in a csv file
<table class="table table-hover table-responsive">
<tbody><tr>
<td style="vertical-align: middle; width: 20%;" class="hidden-xs">
<img class="retailer-logo" data-placement="right" src="/images/20180813125BhYNMEK8lgOpXj3zxze53WmqeRWov7h.jpg" alt="Contact Energy" style="width:150px;" title="" data-original-title="" />
</td>
<td style="vertical-align: middle; width: 75px;" class="hidden-xs">
<img src="/images/result-arrow.png" />
</td>
<td>
<table style="width: 100%;">
<tbody><tr class="visible-xs">
<td class="text-center" colspan="2">
<img class="retailer-logo" data-placement="right" src="/images/20180813125BhYNMEK8lgOpXj3zxze53WmqeRWov7h.jpg" alt="Contact Energy" style="width:150px;" title="" data-original-title="" />
</td>
</tr>
<tr>
<td colspan="3"><h4>Contact Energy Saver Plus</h4></td>
</tr>
<tr style="text-transform: uppercase">
<td width="150px">Electricity:</td>
<td>$242.85 <a class="plan-breakdown" data-placement="right" title="" data-original-title="<table><tr><td>Anytime</td><td>$0.334</td><td>per kWh</td><tr><td>Daily</td><td>$0.333</td><td>per day</td><tr><td>EA Levy</td><td>$0.0013</td><td>per kWh</td></table>"><i class="glyphicon glyphicon-info-sign"> </i></a>
</td>
</tr>
<tr style="text-transform: uppercase">
<td>Discount:</td>
<td>$63.14 (26%)
</td>
</tr>
<tr>
<td colspan="3">
<a class="plan-detail" data-placement="right" title="" data-original-title="<ul><li>Provides fixed pricing until 31 June 2021 unless there are changes to taxes and levies.</li><li>24% Prompt Payment Discount when you pay on time. additional 1% discount for paying by direct debit (excl. credit card), and 1% discount for getting bills and correspondence by email. Up to 26% PPD available.</li><li>An early termination fee of $150 per contracted ICP if you terminate the contract before the end date�(31/06/2021). Fee may be waived if you are moving house and take Contact Energy to the new property.</li><li>Not available to prepay customers.</li></ul>"><i class="glyphicon glyphicon-info-sign"> </i> What you need to know</a>
</td>
</tr>
<tr class="visible-xs">
<td colspan="2">
<h3 class="total">$179.71</h3>
<div class="incentive">
<b style="text-transform: uppercase">SPECIAL SwitchMe OFFER</b><br />
Special PPD & Fixed rates<br />
<a style="font-size: 0.9em;" class="incentive-info" title="" data-original-title="Receive�a special Prompt Payment Discount and fixed rates until 31 June 2021 unless there are changes to taxes and levies">More Info</a>
</div>
</td>
</tr>
<tr class="visible-xs">
<td colspan="2">
<form id="w0" action="/switch/" method="post">
<input type="hidden" name="_csrf" value="Hi21xBvkP6NpUl0UcaFwxn4U5-94Jj8KqEeprOfuG9tMfP2gStRY6RFrBGdF6gGvT0uM3CAQaVvOPpnq1IddtQ==" /> <input type="hidden" name="query_id" value="409884" /> <input type="hidden" name="plan_group_id" value="54" /> <input type="hidden" name="plan_stage_id" value="367" /> <button type="submit" class="btn btn-block btn-switch" style="max-width: 100%; margin-top: 10px">Switch Now!</button> </form> <div class="wannatalk" style="max-width: 100%">
Want to talk?<br />
Call our friendly team on<br />
<b>0800 179 482</b>
</div>
</td>
</tr>
</tbody></table>
</td>
<td style="text-align: center" class="hidden-xs">
<h3 class="total">$179.71</h3>
<div class="incentive">
<b style="text-transform: uppercase">SPECIAL SwitchMe OFFER</b><br />
Special PPD & Fixed rates<br />
<a style="font-size: 0.9em;" class="incentive-info" title="" data-original-title="Receive�a special Prompt Payment Discount and fixed rates until 31 June 2021 unless there are changes to taxes and levies">More Info</a>
</div>
</td>
<td class="hidden-xs">
<form id="w1" action="/switch/" method="post">
<input type="hidden" name="_csrf" value="Hi21xBvkP6NpUl0UcaFwxn4U5-94Jj8KqEeprOfuG9tMfP2gStRY6RFrBGdF6gGvT0uM3CAQaVvOPpnq1IddtQ==" /> <input type="hidden" name="query_id" value="409884" /> <input type="hidden" name="plan_group_id" value="54" /> <input type="hidden" name="plan_stage_id" value="367" /> <button type="submit" class="btn btn-block btn-switch">Switch Now!</button> </form> <div class="wannatalk">
Want to talk?<br />
Call our friendly team on<br />
<b>0800 179 482</b>
</div>
</td>
</tr>
<tr>
<td style="vertical-align: middle; width: 20%;" class="hidden-xs">
<img class="retailer-logo" data-placement="right" src="/images/20171013102LzWd_kdtQOk4yxxyZuCZBG6q7xIuClx.jpg" alt="Powershop" style="width:150px;" title="" data-original-title="" />
</td>
<td style="vertical-align: middle; width: 75px;" class="hidden-xs">
<img src="/images/result-arrow.png" />
</td>
<td>
<table style="width: 100%;">
<tbody><tr class="visible-xs">
<td class="text-center" colspan="2">
<img class="retailer-logo" data-placement="right" src="/images/20171013102LzWd_kdtQOk4yxxyZuCZBG6q7xIuClx.jpg" alt="Powershop" style="width:150px;" title="" data-original-title="" />
</td>
</tr>
<tr>
<td colspan="3"><h4>Powershop Saver</h4></td>
</tr>
<tr style="text-transform: uppercase">
<td width="150px">Electricity:</td>
<td>$183.40 <a class="plan-breakdown" data-placement="right" title="" data-original-title="<table><tr><td>Anytime</td><td>$0.2508</td><td>per kWh</td><tr><td>Daily</td><td>$0.30</td><td>per day</td><tr><td>EA Levy</td><td>$0.00</td><td>per kWh</td></table>"><i class="glyphicon glyphicon-info-sign"> </i></a>
</td>
</tr>
<tr style="text-transform: uppercase">
<td>Discount:</td>
<td>$0.00 (0%)
</td>
</tr>
<tr>
<td colspan="3">
<a class="plan-detail" data-placement="right" title="" data-original-title="<ul><li>The price estimate is based on forecast charges from Powershop for the next 12 months.</li><li>It assumes you purchase the Powershop Simple Saver powerpack once a month and special powerpacks that are made available from time to time.</li><li>This offer does not require a contract or a minimum supply period.</li><li>New customers will get a $150 power credit applied over their first 12 months ($25 straight away, $10 on the next 10�monthly account
review periods, and a final credit of $25 in the final account review period of
your first year as a Powershop customer).�</li></ul>"><i class="glyphicon glyphicon-info-sign"> </i> What you need to know</a>
</td>
</tr>
<tr class="visible-xs">
<td colspan="2">
<h3 class="total">$183.40</h3>
<div class="incentive">
<b style="text-transform: uppercase">SPECIAL SwitchMe OFFER</b><br />
Get $150 off your bill over 12 months!<br /> <a style="font-size: 0.9em;" class="incentive-info" title="" data-original-title="<div><div>New customers will get a $150 power credit applied over their first 12 months ($25 straight away, then $10 for the next 10�monthly account
review periods, and a final credit of $25 in the final account review period of
your first year as a Powershop customer).</div><div>�</div></div><div><br></div><div><br></div>">More Info</a> </div>
</td>
</tr>
<tr class="visible-xs">
<td colspan="2">
<form id="w2" action="/switch/" method="post">
<input type="hidden" name="_csrf" value="Hi21xBvkP6NpUl0UcaFwxn4U5-94Jj8KqEeprOfuG9tMfP2gStRY6RFrBGdF6gGvT0uM3CAQaVvOPpnq1IddtQ==" /> <input type="hidden" name="query_id" value="409884" /> <input type="hidden" name="plan_group_id" value="53" /> <input type="hidden" name="plan_stage_id" value="273" /> <button type="submit" class="btn btn-block btn-switch" style="max-width: 100%; margin-top: 10px">Switch Now!</button> </form><div class="wannatalk" style="max-width: 100%">
Want to talk?<br />
Call our friendly team on<br />
<b>0800 179 482</b>
</div>
</td>
</tr>
</tbody></table>
</td>
so the output should be:
from td[3] and td[4] in first row:
Contact Energy Saver Plus
$179.71
and then the next row:
Powershop Saver
$183.40
and so on until the last row ( of the main table).
Similar process to that given in comments but different selectors
from bs4 import BeautifulSoup as bs
html = '''yourhtml'''
soup = bs(html, 'lxml')
names = [item.text for item in soup.select('.table h4 ')]
prices = [item.text for item in soup.select('[colspan="2"] > .total')]
results = list(zip(names, prices))
print(results)
I actually managed to solve this with using regex. I like the approach in the above answer much better specially using zip(), but I though pasting my solution here in case it becomes handy to some other readers.
deals=[]
prices=[]
results={}
with open("prices.html", "r") as f:
soup = BeautifulSoup(f, 'html.parser')
priceTable = soup.find('table', attrs={"class":"table table-hover table-responsive"})
tbody = priceTable.find('tbody')
pplanPattern = '<td\ colspan="3"><h4>([^<]+)<\/h4><\/td>'
pricePatterns = '<h3 class="total">([^<]+)<\/h3>'
for rw in tbody:
plan = re.search(pplanPattern, rw)
price = re.search(pricePatterns, rw)
if plan:
deals.append(plan.group(1))
if price:
deals.append(price.group(1))
results[plan.group(1)] = price.group(1)

For loop with Beautiful Soup throwing error

I have created this for loop to find td items that start with 'td_threadtitle':
for item in posts:
hello = item.find("td", {"id": lambda L: L and L.startswith('td_threadtitle')})
print(hello)
But I get this error:
hello = item.find("td", {"id": lambda L: L and L.startswith('td_threadtitle')})
TypeError: slice indices must be integers or None or have an __index__ method
When I change the variable hello to this:
hello = item.find("td") , it works perfectly fine. Why does it throw that error when I try to specify the id?
EDIT:
This is how I created posts:
tableWithPosts = soup.find("body").find("div", attrs = {"align": "center"}).find("div", {"class" : "page"}).find("div", attrs = {"style" : "padding:0px 0px 0px 0px"}).find("center").find("form").find("table", {"id": "threadslist"})
posts = tableWithPosts.find("tbody", {"id": "threadbits_forum_75"}
Here is a portion of posts:
</a>
)
</span>
</div>
<div class="smallfont">
<span onclick="window.open('member.php?s=625e629b088a68126ca2d867c056b363&u=206824', '_self')" style="cursor:pointer">
thelavenhagen
</span>
</div>
</td>
<td class="alt2" title="Replies: 11, Views: 1,471">
<div class="smallfont" style="text-align:right; white-space:nowrap">
Thu, May-25-2017
<span class="time">
05:06:46 AM
</span>
<br/>
by
<a href="member.php?s=625e629b088a68126ca2d867c056b363&find=lastposter&t=581132" rel="nofollow">
westopher
</a>
<a href="showthread.php?s=625e629b088a68126ca2d867c056b363&p=1067660274#post1067660274">
<img alt="Go to last post" border="0" class="inlineimg" src="images/buttons/lastpost.gif"/>
</a>
</div>
</td>
<td align="center" class="alt1">
<a href="misc.php?do=whoposted&t=581132" onclick="who(581132); return false;">
11
</a>
</td>
<td align="center" class="alt2">
1,471
</td>
</tr>
<tr>
<td class="alt1" id="td_threadstatusicon_558556">
<img alt="" border="" id="thread_statusicon_558556" src="images/statusicon/thread_hot.gif"/>
</td>
<td class="alt2">
<img alt="" border="0" src="images/icons/icon1.gif"/>
</td>
<td class="alt1" id="td_threadtitle_558556" title="1996 E36 M3 Lux Dakar Yellow, 87,800 miles, special order without sunroof. Second owner, owned...">
<div>
<span style="float:right">
<a href="#" onclick="attachments(558556); return false">
<img alt="4 Attachment(s)" border="0" class="inlineimg" src="images/misc/paperclip.gif"/>
</a>
</span>
<span style="color: blue">
<b>
<u>
FS:
</u>
</b>
</span>
<a href="showthread.php?s=625e629b088a68126ca2d867c056b363&t=558556" id="thread_title_558556">
1996 E36 M3 - Dakar Lux Slicktop
</a>
<span class="smallfont" style="white-space:nowrap">
(
<img alt="Multi-page thread" border="0" class="inlineimg" src="images/misc/multipage.gif"/>
<a href="showthread.php?s=625e629b088a68126ca2d867c056b363&t=558556">
1
</a>
<a href="showthread.php?s=625e629b088a68126ca2d867c056b363&t=558556&page=2">
2
</a>
<a href="showthread.php?s=625e629b088a68126ca2d867c056b363&t=558556&page=3">
3
</a>
)
</span>
</div>
<div class="smallfont">
<span onclick="window.open('member.php?s=625e629b088a68126ca2d867c056b363&u=95931', '_self')" style="cursor:pointer">
yellowbee
</span>
</div>
</td>
<td class="alt2" title="Replies: 23, Views: 5,147">
<div class="smallfont" style="text-align:right; white-space:nowrap">
Thu, May-25-2017
<span class="time">
04:04:07 AM
</span>
<br/>
by
<a href="member.php?s=625e629b088a68126ca2d867c056b363&find=lastposter&t=558556" rel="nofollow">
mbausa
</a>
<a href="showthread.php?s=625e629b088a68126ca2d867c056b363&p=1067660244#post1067660244">
<img alt="Go to last post" border="0" class="inlineimg" src="images/buttons/lastpost.gif"/>
</a>
</div>
</td>
<td align="center" class="alt1">
<a href="misc.php?do=whoposted&t=558556" onclick="who(558556); return false;">
23
</a>
</td>
<td align="center" class="alt2">
5,147
</td>
</tr>
<tr>
<td class="alt1" id="td_threadstatusicon_580693">
<img alt="" border="" id="thread_statusicon_580693" src="images/statusicon/thread_hot.gif"/>
</td>
<td class="alt2">
<img alt="" border="0" src="images/icons/icon1.gif"/>
</td>
<td class="alt1" id="td_threadtitle_580693" title="Selling my wife's car. We have owned her for two years and have put over 20k hassle free miles on...">
<div>
<span style="color: blue">
<b>
<u>
FS:
</u>
</b>
</span>
<a href="showthread.php?s=625e629b088a68126ca2d867c056b363&t=580693" id="thread_title_580693">
2011 BMW 740Li Alpine White M Package Dakota Brown Interior Weather-tech Mats
</a>
</div>
<div class="smallfont">
<span onclick="window.open('member.php?s=625e629b088a68126ca2d867c056b363&u=128641', '_self')" style="cursor:pointer">
911-AL
</span>
</div>
</td>
Remove your for loop, try with this:
hello = posts.find_all("td", {"id": lambda L: L and L.startswith('td_threadtitle')})
hello
It will find all td items that start with 'td_threadtitle'
hello will be a list which contains all td(objects <class 'bs4.element.Tag'> ) start with 'td_threadtitle', you can still access their div.

Use beautifulsoup for pick complete-set of data with specfic criteria id

Can I filter-out all no data in id="time_xxxxxx" and id="odds_3_xxxxxx" from all tags which contain in <tr id="tr_xxxxxx">, and just display all has data in id="time_xxxxxx" and id="odds_3_xxxxxx"?
from this HTML code have one <tr> tag which contains id="tr_xxxxxxx
<tr> </tr>
in this tag contain two set of data
<td id="odds_3_xxxxxxx"></td>
<div id="time_xxxxx"> </div>
but I just want to get the tag which has completed set of the data which just first set of id="odds_3_xxxxxx" was ok.
In this html table, the data pattern are following:
first set (data complete-set)
second set (no time data)
third set (just has time data)
HTML:
<tr style="display: none;" id="tr_976952" index="0" align="center" bgcolor="#F7F3F7" height="15">
<div id="time_1039509">
42
<img src="images/in.gif" border="0">
</div>
<td width="90" id="odds_3_1039509" title="">
<a class="sb" href="javascript:" onclick="ChangeDetail3(1039509,'3')">0.94</a>
<img src="images/t3.gif">
<br>
<a class="pk" href="javascript:" onclick="ChangeDetail3(1039509,'3')">2.5/3</a>
<br>
0.86
</td>
<td width="90" id="odds_4_1234567" title="">
<a class="sb" href="javascript:" onclick="ChangeDetail3(1039509,'3')">0.12</a>
<img src="images/t3.gif">
<br>
<a class="pk" href="javascript:" onclick="ChangeDetail3(1039509,'3')">3</a>
<br>
0.41
</td>
</tr>
<tr style="display: none;" id="tr_654654" index="0" align="center" bgcolor="#F7F3F7" height="15">
<div id="time_654654">
<img src="images/in.gif" border="0">
</div>
<td width="90" id="odds_3_654654" title="">
<a class="sb" href="javascript:" onclick="ChangeDetail3(654654,'3')">0.88</a>
<img src="images/t3.gif">
<br>
<a class="pk" href="javascript:" onclick="ChangeDetail3(654654,'3')">1.5</a>
<br>
0.86
</td>
<td width="90" id="odds_4_1234567" title="">
<a class="sb" href="javascript:" onclick="ChangeDetail3(654654,'3')">0.77</a>
<img src="images/t3.gif">
<br>
<a class="pk" href="javascript:" onclick="ChangeDetail3(654654,'3')">2</a>
<br>
0.66
</td>
</tr>
<tr style="display: none;" id="tr_534589" index="0" align="center" bgcolor="#F7F3F7" height="15">
<div id="time_534589">
50
<img src="images/in.gif" border="0">
</div>
<td width="90" id="odds_3_534589" title=""></td>
<td width="90" id="odds_4_534589" title="">
<a class="sb" href="javascript:" onclick="ChangeDetail3(534589,'3')">0.99</a>
<img src="images/t3.gif">
<br>
<a class="pk" href="javascript:" onclick="ChangeDetail3(534589,'3')">6</a>
<br>
0.74
</td>
</tr>
Code: (for my code will display all data, but I just need to complete-set of data, if the data are not in complete-set, I don't want to display)
rows = table.findAll("tr", {"id" : re.compile('tr_*\d')})
cols = soup.find_all(["div", "td"], id=re.compile('^(odds_3|time)_\d+$'))
data = [t.strip()
for tag in cols
for t in tag.find_all(text=True) if t.strip()]
print '; '.join(data)
Output:
42; 0.94 ; 2.5/3 ; 0.86
0.88 ; 1.5 ; 0.86
50
Expected Output:
42; 0.94 ; 2.5/3 ; 0.86
Why don't you just filter what gets printed like this:
if len(data) == 4:
print '; '.join(data)

Regex handling of a phrase that may occur once or twice

I really couldn't think of a decent title to give a overview of what I'm trying to do, but the examples I have should explain it nicely, my company provides a schedule online, but they don't have any APIs or anything to extract it, so I'm using the Python framework Scrapy to scrape the data, and then adding it to my Google Calendar
A girl gave me a Regex line to handle the data because it was kicking my butt for days and she was feeling nice, but I've since realized that it doesn't handle split shifts (most likely because I was not scheduled for any so she didn't see the possibility of one)
My regex is
re.findall("""dow1'>(\w+)<\S+?>(\w+ \d+)</td>\s*<td class.*?tlHours'>(\d+).*?span>\s*(\d+)<span.*?ment'>(.*?)</spa.*?Meal: (.*?)</sp.*?start'>(\S+?)</spa.*?end'>(\S+?)<""", response.body)
Example data:
This is a normal 8 hour day with a meal break, which is handled fine:
<tr>
<td class='dt'>
<span class='dow1'>Sunday</span>Dec 09
</td>
<td class='ScheduledDetails'valign='top'>
<div style="position:relative;">
<span class='tlHours'>8<span class='spart'> hrs</span> 0<span class='spart'> mins</span></span><span class='department'>Cashier</span><span class='meal'>Meal: 2pm - 3pm</span>
</div>
</td>
<td>
</td>
<td class='Schedunderlay'>
<div class='Sched'>
<div class='schedbar' style='left: 143px; width: 234px;'>
<div class='schedbar_l'></div>
<div class='schedbar_m' style='width: 226px;'>
<span class='start'>10am</span><span class='end'>7pm</span>
</div>
<div class='schedbar_r'></div>
</div>
<div class='availbar' style='left: 9px; width: 498px; display: none;'>
<div class='schedbar_l'></div>
<div class='schedbar_m' style='width: 490px;'>
<span class='start'><img src='/Images/Schedule/arrowLeft.gif' alt='' style='margin-left:5px; margin-top:2px;' /></span>
<div class='OTtext' align='center'>All Day</div>
<span class='end'></span>
</div>
<div class='schedbar_r'></div>
</div>
<div class='availbar' style='left: 508px; width: 216px; display: none;'>
<div class='schedbar_l_on'></div>
<div class='schedbar_m_on' style='width: 208px;'><span class='start'></span>
<div class='OTtext' align='center'>All Day</div>
<span class='end'><img src='/Images/Schedule/arrowRight.gif' alt='' style='margin-left:5px; margin-top:2px;' /></span>
</div>
<div class='schedbar_r_on'></div>
</div>
</div>
</td>
<td> </td>
<td class='rightColDetails'>
<div class='AvailDetails' align='left' style='display: table-cell;'>
<span class='iefix'><b>Avail - All Day</b></span><br/>
<span style='font-size: 11px;'>Pref - All Day</span>
</div>
</td>
</tr>
And this is a split shift, two four hour shifts separated by a empty 1 hour slot (they do this to cheat the scoring system, two covered shifts instead of one):
<tr>
<td class='dt'>
<span class='dow1'>Thursday</span>Dec 13
</td>
<td class='ScheduledDetails' valign='top'>
<div style="position:relative;">
<span class='tlHours'>8<span class='spart'> hrs</span> 0<span class='spart'> mins</span></span><span class='department'>Cashier</span><span class='meal'>Meal: None</span>
</div>
</td>
<td> </td>
<td class='Schedunderlay'>
<div class='Sched'>
<div class='schedbar' style='left: 247px; width: 104px;'>
<div class='schedbar_l'></div>
<div class='schedbar_m' style='width: 96px;'>
<span class='start'>2pm</span><span class='end'>6pm</span>
</div><div class='schedbar_r'></div>
</div>
<div class='schedbar' style='left: 377px; width: 104px;'>
<div class='schedbar_l'></div>
<div class='schedbar_m' style='width: 96px;'>
<span class='start'>7pm</span> <span class='end'>11pm</span>
</div>
<div class='schedbar_r'></div>
</div>
<div class='availbar' style='left: 9px; width: 498px; display: none;'>
<div class='schedbar_l'></div><div class='schedbar_m' style='width: 490px;'>
<span class='start'><img src='/Images/Schedule/arrowLeft.gif' alt='' style='margin-left:5px; margin-top:2px;' /></span>
<div class='OTtext' align='center'>All Day</div>
<span class='end'></span>
</div>
<div class='schedbar_r'></div>
</div>
<div class='availbar' style='left: 508px; width: 216px; display: none;'>
<div class='schedbar_l_on'></div>
<div class='schedbar_m_on' style='width: 208px;'>
<span class='start'></span>
<div class='OTtext' align='center'>All Day</div>
<span class='end'><img src='/Images/Schedule/arrowRight.gif' alt='' style='margin-left:5px; margin-top:2px;' /></span>
</div>
<div class='schedbar_r_on'></div>
</div>
</div>
</td>
<td> </td>
<td class='rightColDetails'>
<div class='AvailDetails' align='left' style='display: table-cell;'>
<span class='iefix'><b>Avail - All Day</b></span><br/><span style='font-size: 11px;'>Pref - All Day</span>
</div>
</td>
</tr>
The important difference is on the regular shift there's one start and one end time, with the split shift there's a start, and end, and start, and end....
I've been pounding my head against this for about five hours now... and making no headway, I suppose I'd have more luck if I understood Regex.. any help at all would be greatly appreciated...
Here is a solution using BeautifulSoup to parse the document and grab the info.
from bs4 import BeautifulSoup
soup = BeautifulSoup(html)
for schedbar in soup.find_all('div', 'schedbar'):
print "start: " + schedbar.find('div', 'schedbar_m').find('span', 'start').string
print "end: " + schedbar.find('div', 'schedbar_m').find('span', 'end').string
Outputs:
start: 2pm
end: 6pm
start: 7pm
end: 11pm

Categories

Resources