main.py
import pymysql
import re
import requests
from bs4 import BeautifulSoup
def insertCvpr(value):
try:
db = pymysql.connect(host="localhost", user="root", password="password", database="article",charset="utf8")
print("数据库连接成功!")
cur = db.cursor()
sql = 'INSERT INTO cvpr(title,ab,author,hotword,pdf,path) VALUE (%s,%s,%s,%s,%s,%s)'
cur.execute(sql, value)
db.commit()
print("增加数据成功!")
except pymysql.Error as e:
print("增加数据失败: " + str(e))
db.rollback()
db.close()
#主函数
print("1")
url = "https://openaccess.thecvf.com/CVPR2020.py?day=2020-06-16"
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36"}
res = requests.get(url,headers=headers)
res.encoding = "utf-8"
web = re.findall("""
2.数据库
遇到的问题:
注意varchar最大长度为255,数据长度可能不够,使用longtext类型存储。
手机扫一扫
移动阅读更方便
你可能感兴趣的文章