以下是重构后的代码:
```python
# 滚石30周年演唱会评分
document.write("
排行榜")
# 分享
share_buttons = [
{
"channelId": 1,
"action": "copy_url"
},
{
"channelId": 2,
"action": "like"
},
{
"channelId": 3,
"action": "comment"
}
]
# 将分享按钮转换为HTML代码
def generate_share_buttons(share_buttons):
html = '
- '
- {button["channelId"]} '
for button in share_buttons:
html += f'
html += '
return html
# 生成分享按钮的HTML代码并插入到页面中
generate_share_buttons(share_buttons)
```