提取oracle数据库HTML内容转换成正文格式

提取oracle数据库HTML内容转换成正文格式(去标签)在更新到同表的TZNR

# -*- coding:utf-8 -*-
import cx_Oracle
from bs4 import BeautifulSoup


conn = cx_Oracle.connect('用户名', '用户密码', 'localhost:1521/ORCL')
cur = conn.cursor()

sql_search = 'select WZ,HTML from 表名'
res = cur.execute(sql_search)
# html = cur.fetchone()
rows = cur.fetchall() #得到所有数据集
for row in rows:
    # print(row[0])
    html = BeautifulSoup(row[1],'lxml').text
    # print(html)
    upsql = "UPDATE 表名 t SET t.TZNR = :TZNR WHERE t.WZ = :WZ"
    cur.prepare(upsql)
    cur.execute(None, {'TZNR': html,'WZ': row[0]})
    print('sucess!!!')
    conn.commit()

cur.close()
conn.close()

猜你喜欢

转载自blog.csdn.net/qq_41928442/article/details/82976290
今日推荐