爱看小说的程序猿必备!
首先我们需要安装以下库:
python3.5
requests
pymysql
lxml
queue
threading
import requests
from lxml import etree
import pymysql
def insertdb():
url = "http://www.xbiquge.la/xiaoshuodaquan/"
# 获取响应
req = requests.get(url)
html = etree.HTML(req.content.decode("utf8", "ignore"))
lists = html.xpath("//div[@class='novellist']/ul/li")
#链接数据库
db = pymysql.connect(host='localhost', port=3306, user='root', password='123456', db='biquge&