Wednesday, 15 June 2011

python - Print the results from re.findall on a seperate line in Python3 -



python - Print the results from re.findall on a seperate line in Python3 -

i want print findall results on new line every match

python code import urllib.request import re htmlfile = urllib.request.urlopen("http://basketball.realgm.com/") htmltext = htmlfile.read().decode('iso-8859-1') title = re.findall('">(.+?)</a></h3>', htmltext) print (title) results ['lebron james exercises termination alternative heat', 'lebron james exercises termination alternative heat', 'heat, hawks bring together pursuit of carmelo anthony', 'tyler dorsey decommits arizona', 'antoine mason transfers auburn', 'dario saric signs three-year deal anadolu efes', 'batum participate in fiba world cup france', 'moustapha diagne commits syracuse'] want results this: lebron james exercises termination alternative heat heat, hawks bring together pursuit of carmelo anthony tyler dorsey decommits arizona

tried:

print (title \n)

just

print("\n".join(title))

python regex web-scraping

No comments:

Post a Comment