<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      抽取網易云音樂熱門評論:html+css+python+js 音樂與靈魂的碰撞

      抽取網易云音樂熱門評論:html+css+python+js 音樂與靈魂的碰撞

      代碼鏈接
      效果展示
      不說廢話,上代碼!!!

      get.py

      # get.py
      import urllib.request
      import urllib.error
      import urllib.parse
      import json
      
      
      # 抓取網易云音樂指定url的熱評
      def get_hotComments(id):
          url = 'https://music.163.com/weapi/v1/resource/comments/R_SO_4_'+id+'?csrf_token='   # 歌評url
          header = {'User-Agent': "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1"}
      
          # post請求表單數據
          data = {'params':'LPkOcWb/uz2Nj6xw+RFhGJ1PkFi4+lh4agK+1jRGmjMAiOcJ5RHxQBbZa+aME54AUdi21JkqLu/yeHjjIaLQJ4wzqiuzrzYUKciRCqmCDX9ziKoktv5mgvvlA5+A9a7kUF5pabudBaWjsut+9T5kfHQBv75fIcDRt/Anyb8FnG/Ro6R8IStD0/JknFvH5+3S',
                  'encSecKey':'5627cc7941cf4cbd59b13668efe38a622ed0889d33cdcf603d18b025eb34ac434c882ed5ad16ca06e88e40a8b91de455483d0b88b6b460ca146b163e67ebab688b2feb4f22369db85a926744bad9114d3cddd00ca6255d7cdcad6cf7b9300a6fdf49adf983087cd830131fabbac39ec4a526432958309cf92c0b5a6bc177078b'}
          postdata = urllib.parse.urlencode(data).encode('utf8')  # 進行編碼
          request = urllib.request.Request(url, headers=header, data=postdata)
          response = urllib.request.urlopen(request).read().decode('utf8')
          json_dict = json.loads(response)   # 獲取json
          hot_comment = json_dict['hotComments']  # 獲取json中的熱門評論
          print(id)
          num = 1
          for item in hot_comment:
              printer1=item['content']
              with open("comments.txt","a",encoding='utf-8') as f:
                  f.write('id : '+id+' : '+printer1)
                  f.write("\n")
                  f.close()
              print('id : '+id+' '+'第%d條評論:' % num+printer1)
              num += 1
      
      if __name__ == '__main__':
          id=input()
          get_hotComments(id)
      

      index.py

      import get as g
      n=int(input())
      while 1:
      	g.get_hotComments(str(n))
      	n=n+1
      

      注:n為網易云音樂歌曲id。
      例如:網易云音樂鏈接:https://music.163.com/#/song?id=2016388286
      id為2016388286
      id通常為8位-10位數字。
      結尾附上部分comments.txt文件

      index.html

      重頭戲來了!

      <!DOCTYPE html>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <title>隨機云村評論</title>
          <style>
              body {
                  margin: 0;
                  padding: 0;
                  font-family: 'Arial', sans-serif;
                  background: linear-gradient(135deg, #1e272e, #2c3e50);
                  color: #ffffff;
                  overflow-x: hidden;
                  display: flex;
                  justify-content: center;
                  align-items: center;
                  height: 100vh;
                  text-align: center;
              }
              .container {
                  max-width: 800px;
                  padding: 40px;
                  border-radius: 10px;
                  background: rgba(0, 0, 0, 0.6);
                  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
                  backdrop-filter: blur(5px);
              }
              .container h1 {
                  font-size: 3rem;
                  margin: 0 0 20px;
              }
              .container h2 {
                  font-size: 1.5rem;
                  margin: 0 0 15px;
              }
              .container p {
                  font-size: 1.2rem;
                  margin: 20px 0;
              }
              .button {
                  padding: 10px 20px;
                  background: #00ff80;
                  border: none;
                  border-radius: 5px;
                  font-size: 1.2rem;
                  color: #1e272e;
                  cursor: pointer;
                  transition: transform 0.3s ease, background 0.3s ease;
              }
              .button:hover {
                  background: #00e676;
                  transform: scale(1.1);
              }
              a {
                  color: #00ff80;
                  text-decoration: none;
                  transition: color 0.3s ease;
              }
              a:hover {
                  color: #00e676;
                  text-decoration: underline;
              }
              .particles {
                  position: fixed;
                  top: 0;
                  left: 0;
                  width: 100%;
                  height: 100%;
                  z-index: -1;
              }
              .music-player {
                  margin-top: 20px;
              }
          </style>
      </head>
      <body>
          <canvas class="particles"></canvas>
          <div class="container">
              <h1>隨機云村評論</h1>
              <h2>音樂與靈魂的碰撞</h2>
              <a href="/">返回首頁</a>
              <p id="comment">點擊按鈕隨機抽取一條評論</p>
              <button class="button" onclick="fetchRandomComment()">抽取評論</button>
              <div class="music-player" id="musicPlayer"></div>
          </div>
          <script>
              let comments = [];
      
              // 從服務器加載評論文件
              async function loadComments() {
                  try {
                      const response = await fetch('comments.txt');
                      if (!response.ok) {
                          throw new Error('Failed to fetch comments');
                      }
                      const fileContent = await response.text();
                      comments = parseComments(fileContent);
                      document.getElementById('comment').textContent = "點擊按鈕隨機抽取一條評論";
                  } catch (error) {
                      console.error("Failed to load comments:", error);
                      document.getElementById('comment').textContent = "加載評論失敗,請稍后再試。";
                  }
              }
      
              // 解析評論內容
              function parseComments(fileContent) {
                  const lines = fileContent.split('\n');
                  const parsedComments = [];
                  let currentComment = null;
      
                  lines.forEach(line => {
                      const trimmedLine = line.trim();
                      if (trimmedLine === "") return;
      
                      const parts = trimmedLine.split(' : ');
                      if (parts.length >= 3) {
                          if (currentComment) {
                              parsedComments.push(currentComment);
                          }
                          currentComment = { id: parts[0].trim(), number: parts[1].trim(), content: parts.slice(2).join(' : ').trim() };
                      } else if (currentComment) {
                          currentComment.content += "\n" + trimmedLine;
                      }
                  });
      
                  if (currentComment) {
                      parsedComments.push(currentComment);
                  }
      
                  return parsedComments;
              }
      
              // 隨機抽取評論
              function fetchRandomComment() {
                  if (comments.length === 0) {
                      loadComments();
                      return;
                  }
      
                  const randomIndex = Math.floor(Math.random() * comments.length);
                  const comment = comments[randomIndex];
                  const songUrl = `https://music.163.com/#/song?id=${comment.number}`;
                  document.getElementById('comment').innerHTML = `來自歌曲<a href="${songUrl}" target="_blank">${comment.number}</a>的評論:${comment.content}`;
                  const musicPlayerDiv = document.getElementById('musicPlayer');
                  musicPlayerDiv.innerHTML = `<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="http://music.163.com/outchain/player?type=2&id=${comment.number}&auto=1&height=66"></iframe>`;
              }
      
              // 初次加載時嘗試加載評論
              loadComments();
      
              // 粒子效果
              document.addEventListener('DOMContentLoaded', () => {
                  const canvas = document.querySelector('.particles');
                  const ctx = canvas.getContext('2d');
      
                  canvas.width = window.innerWidth;
                  canvas.height = window.innerHeight;
      
                  window.addEventListener('resize', () => {
                      canvas.width = window.innerWidth;
                      canvas.height = window.innerHeight;
                  });
      
                  const particles = [];
      
                  class Particle {
                      constructor(x, y, color) {
                          this.x = x;
                          this.y = y;
                          this.color = color;
                          this.size = Math.random() * 3 + 1;
                          this.speedX = Math.random() * 2 - 1;
                          this.speedY = Math.random() * 2 - 1;
                      }
      
                      draw() {
                          ctx.fillStyle = this.color;
                          ctx.beginPath();
                          ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
                          ctx.fill();
                      }
      
                      update() {
                          this.x += this.speedX;
                          this.y += this.speedY;
      
                          if (this.x < 0 || this.x > canvas.width) this.speedX *= -1;
                          if (this.y < 0 || this.y > canvas.height) this.speedY *= -1;
                      }
                  }
      
                  function createParticles() {
                      for (let i = 0; i < 100; i++) {
                          const x = Math.random() * canvas.width;
                          const y = Math.random() * canvas.height;
                          const color = `hsl(${Math.random() * 360}, 100%, 50%)`;
                          particles.push(new Particle(x, y, color));
                      }
                  }
      
                  createParticles();
      
                  function animate() {
                      ctx.clearRect(0, 0, canvas.width, canvas.height);
      
                      particles.forEach(particle => {
                          particle.draw();
                          particle.update();
                      });
      
                      requestAnimationFrame(animate);
                  }
      
                  animate();
              });
          </script>
      </body>
      </html>
      

      comments.txt

      格式 :

      id : $id : $comment
      

      部分評論 comments.txt https://github.com/fjsje/wanwusangzhi/blob/main/work/writing/comments.txt

      運行指南

      先打開index.py,輸入起始歌曲id。
      抓取足夠多的評論后,打開index.html
      注意index.html 請在服務器上部署才能抓取comments.txt成功,否則會出現以下情況:
      報錯
      點贊加關注,精彩不迷路!

      posted @ 2025-01-22 12:03  愛玩游戲的jason  閱讀(43)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 久久国产乱子伦免费精品| 无码熟妇人妻av在线电影| 夜夜添无码一区二区三区| 亚洲国产日韩一区三区| 成人嫩草研究院久久久精品| 亚洲国产精品成人无码区| 噜妇插内射精品| 亚洲第一区二区三区av| 亚洲日韩国产二区无码| 国产成人高清亚洲一区二区| 久久天天躁狠狠躁夜夜婷| 无码人妻精品一区二区三区夜夜嗨 | 奉贤区| 成人精品一区二区三区四| 国产激情艳情在线看视频| 毛片tv网站无套内射tv网站| 亚洲天堂激情av在线| 日本一道一区二区视频| 南漳县| 国产免费一区二区三区在线观看| 国产大陆av一区二区三区| 日韩精品国产中文字幕| 亚洲无人区码一二三四区| 国产一区精品综亚洲av| 国产亚洲精品VA片在线播放| 少妇撒尿一区二区在线视频| 国产96在线 | 亚洲| 日韩一区二区三区亚洲一| 真人性囗交视频| 玉田县| 久久一亚色院精品全部免费 | 亚洲乱色伦图片区小说| 漂亮的保姆hd完整版免费韩国| 久久99久国产麻精品66| av天堂午夜精品一区| 日韩精品中文字幕一线不卡| 亚洲人成色77777在线观看| 亚洲精品国产熟女久久久| 国产精品自在线拍国产手青青机版 | 人妻一区二区三区三区| 广昌县|