I'm programming a ticker to get walmart out of stock and price changes... But I'm stuck: When I try to get the id of the item (ending number in the link) I can't parse it. Here is the code
# -*- coding: utf-8 -*-
import re
import urllib2
def walmart():
fileprod = urllib2.urlopen("http://testh3x.altervista.org/walmart.txt").read()
prods = fileprod.split("|")
print prods
lenp = len(prods)
counter = 0
while 1:
while counter < lenp:
data = urllib2.urlopen(prods[counter]).read()
path = re.compile("class=\"Outofstock\"") #\s space - \w char - \W Tutto meno che char -
matching = path.match(data)
if matching == None:
pass
else:
print "Out of stock"
name = re.compile("\d")
m = name.match(str(prods[counter])).group #prods counter è il link
print m
def main():
walmart()
if __name__ == "__main__":
main()
It throws:
File "C:\Users\Leonardo\Desktop\BotDevelop\ticker.py", line 22, in walmart
m = name.match(str(prods[counter])).group #prods counter è il link
AttributeError: 'NoneType' object has no attribute 'group'