I'm trying to do some scraping using Python 2.7.2. I've just started with Python and unfortunately it is not as intuitive as I thought it will be. I try to collect all specific -s from all pages. I don't know how to accumulate results from all pages in string array. So far I'm getting results from 1 page only. I know that this is a super easy question for people who write in python. So please help me. Here is the code:
import urllib
import re
j=1
while j<10:
url="http://www.site.com/search?page=" + str(j) + "&query=keyword"
print url
htmlfile=urllib.urlopen(url)
htmltext=htmlfile.read()
regex='<span class="class33">(.+?)</span>'
pattern=re.compile(regex)
spans=re.findall(pattern,htmltext)
#spans[j] insttead of spans doesn't work
#spans.append(spans) doesn't work
j+=1
i=0
while i<len(spans):
print spans[i]
i+=1