python3快速爬取房源信息,并存入mysql数据库,超详细( 二 )

(.*?)' mytotal=re.findall(totalprice,html.text)#单价 simpleprice=r'(.*?) ' simple=re.findall(simpleprice,html.text) db = pymysql.connect("localhost", "root", "" ,"anjuke") conn = db.cursor() print(len(jpg)) for i in range(0,len(tail)):jpgs = jpg[i]scripts = tail[i]localroom = my[i][0]localarea=my[i][1]localhigh=my[i][2]localtimes=my[i][3]local=my[i][4]total = mytotal[i]oneprice=simple[i]sql = "insert into shanghai_admin value('%s','%s','%s','%s','%s','%s','%s','%s','%s')" %(jpgs,scripts,local,total,oneprice,localroom,localarea,localhigh,localtimes)conn.execute(sql)db.commit() db.close() # button=brower.find_element_by_class_name('aNxt') # button.click() # time.sleep(1) page=page+1# brower.close()
 



推荐阅读