最近打算刷关于数据库的题,对应非会员,只能做题每日一练了,可是刷题时间基本都是地铁上,所以讲题爬下来,用vue做个简单的页面,希望有同样需求的小伙伴来看下,别忘记点赞奥!
python源码(无框架)
# -*- coding: utf-8 -*-
import requests
from lxml import etree
import json
import re
import pandas as pd
import numpy as np
import pymysql
cookie = ""
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36",
"Cookie": cookie,
}
# pymysql 数据库操作
class MysqlAct(object):
def __init__(self):
self.connect = pymysql.connect('localhost', 'root', 'root', 'tpcommon', use_unicode=True, charset='utf8')
self.cursor = self.connect.cursor()
def select(self, sql):
self.cursor.execute(sql)
return self.cursor.fetchall()
def find(self, sql):
self.cursor.execute(sql)
return self.cursor.rowcount
def insert(self, sql):
self.cursor.execute(sql)
self.connect.commit()
def update(self, sql):
self.cursor.execute(sql)
self.connect.commit()
def colose(self):
self.connect.close()
# 爬虫类
class Spider(object):
def __init__(self):
self.page =