Add a new sample file for parsing website results.
Decided to knock up a quick proof of concept for fetching and parsing tournament results from a website. Specifically uses: - Pythons Beautiful Soup library - P5s results pages - replace playername with the desired p5s username (eg. taypaur) Of note; no tournament ids are displayed on any of the sites, so for this to work we may need to add a field like 'p5sid'
This commit is contained in:
parent
958e67beac
commit
f44947c8a0
33
pyfpdb/P5sResultsParser.py
Normal file
33
pyfpdb/P5sResultsParser.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import urllib2, re
|
||||
import pprint
|
||||
from BeautifulSoup import BeautifulSoup
|
||||
|
||||
|
||||
playername = ''
|
||||
|
||||
if playername == '':
|
||||
print "You need to manually enter the playername"
|
||||
exit(0)
|
||||
|
||||
page = urllib2.urlopen("http://www.pocketfives.com/poker-scores/%s/" %playername)
|
||||
soup = BeautifulSoup(page)
|
||||
|
||||
results = []
|
||||
|
||||
for table in soup.findAll('table'):
|
||||
# print "Found %s" % table
|
||||
for row in table.findAll('tr'):
|
||||
tmp = []
|
||||
for col in row.findAll('td'):
|
||||
tmp = tmp + [col.string]
|
||||
#print col.string
|
||||
if len(tmp) > 3 and tmp[2] <> None:
|
||||
results = results + [tmp]
|
||||
|
||||
cols = ['TOURNAMENT', 'SITE', 'DATE', 'PRIZEPOOL', 'BUY-IN', 'PLACE', 'WON']
|
||||
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
||||
for result in results:
|
||||
print "Site: %s Date: %s\tPrizepool: %s\tBuyin: %s\tPosition: %s\tWon: %s" %(result[2], result[3], result[4], result[5], result[6], result[7])
|
||||
|
Loading…
Reference in New Issue
Block a user