main
longchengyun 6 months ago
parent f7e3739b77
commit f95720b9af

@ -62,6 +62,33 @@ def get_url_info(film_url,film_name_en,id):
actor = soup.find(attrs={'id':"info"}).text.split('\n')[3].split(':')[1].strip() actor = soup.find(attrs={'id':"info"}).text.split('\n')[3].split(':')[1].strip()
# 类型 # 类型
filmtype = soup.find(attrs={'id': "info"}).text.split('\n')[4].split(':')[1].strip() filmtype = soup.find(attrs={'id': "info"}).text.split('\n')[4].split(':')[1].strip()
# 片长
runtime = soup.find(attrs={'property': "v:runtime"}).text
# 评分(平均分)
rating_num = soup.find(attrs={'property': "v:average"}).text
# 五星评分比例
stars5_rating_per = soup.find(attrs={'class': "rating_per"}).text
# 评价人数
rating_people = soup.find(attrs={'property': "v:votes"}).text
# 剧情简介
summary = soup.find(attrs={'property': "v:summary"}).text
summary = pymysql.converters.escape_string(summary)
sql = 'insert into movies(film_name,director,scriptwriter,actor,filmtype,area,language,initialrReleaseDate,ranks,runtime,rating_num,stars5_rating_per,rating_people,summary,film_name_en,links) values("{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}");'.format(film_name,director,scriptwriter,actor,filmtype,area,language,initialrReleaseDate,ranks,runtime,rating_num,stars5_rating_per,rating_people,summary,film_name_en,film_url)
db = getDB()
try:
cursor = db.cursor()
cursor.execute(sql)
cursor.execute('insert into moviehash(movieid) values("{}")'.format(id))
db.commit()
except Exception as e:
print(e)
db.rollback()
cursor.close()
db.close()

Loading…
Cancel
Save