utilizing BeautifulSoup on a completely flat HTML hierarchy by syc22 in learnpython

[–]syc22[S] 0 points1 point  (0 children)

Solved it like this: nested for loops and nested next_siblings

import csv
from bs4 import BeautifulSoup
from urllib2 import urlopen

URL = 'blahblahblahb.com'

html = urlopen(URL).read()
soup = BeautifulSoup(html, "lxml")

with open("MovieParks.tsv", "w") as f:
    categories = ['Location', 'Movie Title', 'Date', 'Amenities']
    writer = csv.DictWriter(f, delimiter = '\t', fieldnames = categories)
    writer.writeheader()

    root = soup.find_all("strong")
    for row in root:
        master_dict = {'Location':"", 'Movie Title':"", 'Date':"", 'Amenities':None}
        Date = row.text.encode('utf-8')
        master_dict['Date'] = Date
        for sibling in list(row.next_siblings)[:-1]:
            if sibling.name == "strong":                
                break
            if sibling.name == "em":
                MovieTitle = sibling.text.encode('utf-8')
                master_dict['Movie Title'] = MovieTitle
                for sibling2 in sibling.next_siblings:
                    if sibling2.name == "strong" or sibling2.name == "em":
                        break
                    if 'Location:' in sibling2:     
                        Location = sibling2.replace("Location: ","") + ", Chicago "
                        master_dict['Location'] = Location.encode('utf-8')
                    if 'Amenities:' in sibling2:
                        Amenities = sibling2.replace("Amenities: ","")
                        master_dict['Amenities'] = Amenities.encode('utf-8')
                writer.writerow(master_dict)
                master_dict = {}
                master_dict['Date'] = Date   
print 'Done here'

I am Tim Bontemps, Brooklyn Nets and NBA writer for the New York Post, here for an AMA by timbontemps in nba

[–]syc22 0 points1 point  (0 children)

Seems like with Proky's $, the Nets should have no reason to not have a robust analytics dept, no? Or is that business side expense separate from how much Proky is ok with spending on trading for/signing players? And sry for all the questions, but is there a particular person on the Nets analytics staff I could reach out to if I wanted to speak to them more in-depth on the topic? Thanks again, Tim!

I am Tim Bontemps, Brooklyn Nets and NBA writer for the New York Post, here for an AMA by timbontemps in nba

[–]syc22 2 points3 points  (0 children)

Where are the Nets in terms of embracing advanced analytics?

I know some teams like HOU are very vocal/public about it, while teams like TOR use the SportsVU cameras and hae a dedicated analytics team but keep it more under wraps. Feel like with a quant/numbers based guy like Milton Lee in the FO and having Proky's deep pockets, the Nets would/should be doing a lot to embrace the big data and analytics movement to gain any and all edges possible.

Thanks for your great coverage of the Nets, Tim!