Skip to content

Commit

Permalink
修复 #30 弹幕下载失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
verygoodlee committed May 9, 2024
1 parent caadab2 commit d9f3222
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/bilibiliAssert/Danmu2Ass.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,12 @@ def export(func):


def getComments(cid,font_size = 25):
# url = 'https://comment.bilibili.com/{}.xml'.format(cid[0])
url = ''.join(['https://comment.bilibili.com/',cid[0],'.xml'])
response = request.urlopen(url, context=ssl.SSLContext(ssl.PROTOCOL_TLS))
response = request.urlopen(request.Request(
url = ''.join(['https://comment.bilibili.com/',cid[0],'.xml']),
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0'
}
))
data = str(zlib.decompress(response.read(), -zlib.MAX_WBITS), "utf-8")
response.close()
comments = []
Expand Down

0 comments on commit d9f3222

Please sign in to comment.