Python 美化群到mysql

Python 美化群到mysql,python,mysql,beautifulsoup,Python,Mysql,Beautifulsoup,我在一个站点上找到了这个示例代码,并尝试根据我希望它的工作方式来实现它。不幸的是,原来的代码工作得很好,有多行被刮去的项目,但我修改的那一行只插入了1个项目 from urllib import urlopen from bs4 import BeautifulSoup import pymysql.cursors html = urlopen("https://www.banggood.com/Wholesale-Computer-and-Networking-c-155.html")

我在一个站点上找到了这个示例代码,并尝试根据我希望它的工作方式来实现它。不幸的是,原来的代码工作得很好,有多行被刮去的项目,但我修改的那一行只插入了1个项目

from urllib import urlopen
from bs4 import BeautifulSoup
import pymysql.cursors


html = urlopen("https://www.banggood.com/Wholesale-Computer-and-Networking-c-155.html")


bsObj = BeautifulSoup(html, "html.parser")
recordList = bsObj.findAll("div", {"class": "wrap overflow", })


connection = pymysql.connect(host='localhost',
                             user='root',
                             password='',
                             db='db',
                             charset='utf8mb4',
                             cursorclass=pymysql.cursors.DictCursor)

try:
    with connection.cursor() as cursor:
        for record in recordList:
            title = record.find("span", {"class": 'title', }).get_text().strip()
            artist = record.find("span", {"class": "price wh_cn"}).get_text().strip()
            sql = "INSERT INTO `artist_song` (`artist`, `song`) VALUES (%s, %s)"
            cursor.execute(sql, (artist, title))
    connection.commit()
finally:
    connection.close()

我做错了什么?

出现了任何错误?没有错误“进程结束,退出代码为0”@Sean Francis N.Ballais有什么问题吗?打印(记录列表)?@SeanFrancisN.Ballais的输出是什么