CharlieTian
2018-01-05 16:08:36 +08:00
```
def process_contenturl(url,picture,price,desc):#处理具体商品链接内容
a=requests.get(url)
change=etree.HTML(a.content)
l=change.xpath('//div[@id="attributes"]/ul/li/text()')
stock=change.xpath('//*[@id="J_SpanStock"]/text()')#获取商品库存
for i in range(len(l)):
l[i]=l[i].replace(u'\xa0', '')
if u"上市年份季节" in l[i]:
saleseason=(l[i])[7:]#上市年份季节
elif u"材质成分" in l[i] :
material=(l[i])[5:]#材质成分
elif u"货号" in l[i]:
id=(l[i])[3:]#货号
elif u"适用性别" in l[i]:
gender=(l[i])[5:]#适用性别
else:
remarks="".join(l)#无关紧要的备注
sql="INSERT INTO UNIQLO(id,price,stock,salseason,material,gender,remarks,picture,desc) VALUE (%s,%s,%s,%s,%s,%s,%s,%s,%s)"%(id,price,stock,material,gender,remarks,picture,desc)
print sql
```
想想 id 什么时候才会被定义