hey everyone, for reasons, i needed to grap information from steampowered.co m
where the error is im trying to grab the image to make <img src="blahbla"> http://cdn.steampowered.com/v/gfx/ap...ule_sm_120.jpg
ERROR
nevermind, got it [: thanks anyways
Code:
from BeautifulSoup import BeautifulSoup
from urllib import urlopen
import re
import codecs
html_text = urlopen('http://store.steampowered.com/search/?advanced=0&term=&category1=998').read().decode('iso-8859-1')
soup = BeautifulSoup(html_text)
f = codecs.open('./steamgames.txt', 'w', 'iso-8859-1')
pages = 1
games = 0
print "-- Retrieving number of pages..."
for link in soup.findAll('a', attrs={'href' : re.compile(r"http://store.steampowered.com/search/\?sort_by=&sort_order=ASC&category1=998&page=\d+")}):
try:
page = int(link.string)
if page > pages:
pages = page
except ValueError:
pass
print "-- Pages found:",pages
f.write('<style>body{background-color:#6b91b8;margin-top:16px;}td{font-family:Verdana, Tahoma, Arial, sans-serif;font-size:11px;color:#000;}table{padding-left:2px;background:#f6f6f6;border:1px solid #1a4064;margin-bottom:12px;text-align:left;}.type,.number,.name{background:#efefef;border-bottom:1px solid #d5d5d5;color:#555;font-size:12px;letter-spacing:1px;margin:0;padding:5px;}.type,.number{width:5%;border-right:1px solid #ddd;}.type1,.number1,.name1{margin:0;padding:5px;}.type1,.number1{text-align:center;border-right:1px solid #ddd;border-bottom:1px solid #ddd;}.name1{border-bottom:1px solid #ddd;}</style>') f.write('<table width="100%" cellspacing="0" cellpadding="0">\r\n')
f.write('<tr>\r\n')
f.write('<td class="type">Type</td>\r\n') f.write('<td class="number">#</td>\r\n') f.write('<td class="name">Game</td>\r\n')
f.write('</tr>\r\n')
for page in range(1,pages+1):
print "-- Retrieving page:",page
html_text = urlopen('http://store.steampowered.com/search/?sort_by=&sort_order=ASC&category1=998&page='+str(page)).read().decode('iso-8859-1')
soup = BeautifulSoup(html_text)
for item in soup.findAll('div', attrs={'class' : "global_area_tabs_item"}):
games += 1
appurl = item.find('div', attrs={'class' : "global_area_tabs_item_overlay"}).a['href']
number = re.match(r"http://store.steampowered.com/(\w+)/(\d+)/", appurl)
image = item.find('div', attrs={'class' : "global_area_tabs_item_img"}).img['src']
img = re.match(r"http://cdn.steampowered.com/v/gfx/apps/"(str(appurl)), image)
f.write(str(img)+'\r')
f.write('<tr>\r\n')
f.write('<td class="type1">\r')
f.write(str(number.group(1))+'\r')
f.write('</td>\r\n<td class="number1">\r')
f.write(str(number.group(2))+'\r')
f.write('</td>\r\n<td class="name1">\r')
f.write(item.find('div', attrs={'class' : "global_area_tabs_item_txt"}).h3.string+'</td>\r\n')
f.write('</tr>\r\n')
print "-- Games found:",games
f.write('</table>')
f.close()
ERROR
Code:
-- Retrieving number of pages...
-- Pages found: 46
-- Retrieving page: 1
Traceback (most recent call last):
File "C:\Users\MANKe\Desktop\Steam Tools\steam2.py", line 42, in <module>
img = re.match(r"http://cdn.steampowered.com/v/gfx/apps/"(str(appurl)), image)
TypeError: 'str' object is not callable
Comment