爬取装备列表
import requests
import re
import pymysql
db=pymysql.connect('localhost','root','126315','petzhang')
cursor=db.cursor()
url='http://pvp.qq.com/web201605/js/item.json'
response=requests.get(url)
response=response.json()
for i in range(len(response)):
item = response[i]
sql1='insert into `equip` (`item_id`,`item_name`,`item_type`,`price`,`total_price`) values ("{}","{}","{}","{}","{}")'
sql1=sql1.format(item['item_id'],item['item_name'],item['item_type'],item['price'],item['total_price'])
cursor.execute(sql1)
db.commit()