2020-11-09

等级不够无法自定义标签  VexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlow

心血来潮学了点新东西,用了点时间学会初步使用,但是后续需要的专业知识不太懂,这里留个纪念

vexflow, 一个可以灵活编辑五线谱的好东西(除了index.js是我自己新建的,其余js都可以找到)

html

<!DOCTYPE html>
<html>
<head>
	<meta charset="ISO-8859-1">
	<title>wu</title>
</head>
<script type="text/javascript" src="js/vexflow-min.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/qunit.js"></script>
<script type="text/javascript" src="js/raphael.js"></script>
<script type="text/javascript" src="js/vexflow-debug.js"></script>
<body>
	<div id="boo">
		
	</div>
</body>

</html>

 

index.js


function demo(){
	var div1 = document.getElementById("boo");
	var VF = Vex.Flow;
	var renderer = new VF.Renderer(div1, VF.Renderer.Backends.SVG);

	renderer.resize(500, 500);

	var context = renderer.getContext();

	var stave = new VF.Stave(10, 40, 400);
	stave.addClef("treble").addTimeSignature("4/4");
	stave.setContext(context).draw();
	var notes = [
		new VF.StaveNote({clef: "treble", keys: ["c/4"], duration: "q"}),
		new VF.StaveNote({clef: "treble", keys: ["d/4"], duration: "q"}),
		new VF.StaveNote({clef: "treble", keys: ["b/4"], duration: "qr"}),
		new VF.StaveNote({clef: "treble", keys: ["c/4", "e/4", "g/4"], duration: "q"})
	];
	var notes2 = [
		new VF.StaveNote({clef: "treble", keys: ["c/4"], duration: "w" })
	];
	var voices = [
		new VF.Voice({num_beats: 4,  beat_value: 4}).addTickables(notes),
		new VF.Voice({num_beats: 4,  beat_value: 4}).addTickables(notes2)]

	var formatter = new VF.Formatter().joinVoices(voices).format(voices, 400);

	// Render voices
	voices.forEach(function(v) { v.draw(context, stave); })
}
window.onload = demo;

效果

 

### 使用Python实现抖音评论数据的网络爬取 为了实现这一目标,可以采用多种方法和技术栈组合。以下是基于Selenium和BeautifulSoup库的一种解决方案。 #### 准备工作 安装必要的依赖包: ```bash pip install selenium beautifulsoup4 ``` #### 初始化浏览器驱动 创建一个新的Chrome实例,并设置无头模式以减少资源消耗: ```python from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument("--headless") # 运行时不显示界面 driver = webdriver.Chrome(options=chrome_options) ``` #### 访问目标页面并加载更多评论 通过模拟用户滚动行为触发分页加载机制,从而获取完整的评论区内容: ```python url = 'https://www.douyin.com/video/xxxxxx' # 替换成实际的目标链接 driver.get(url) # 动态加载更多评论 for _ in range(5): # 控制加载次数 driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") time.sleep(2) # 等待新内容加载完成 ``` #### 解析HTML文档结构 利用BeautifulSoup解析DOM树形结构中的`<div class="comment-item">...</div>`节点集合,从中抽取所需字段如用户名、发布时间戳及正文文本等信息[^2]。 ```python from bs4 import BeautifulSoup soup = BeautifulSoup(driver.page_source, 'html.parser') comments = soup.find_all('div', {'class': 'comment-item'}) data = [] for item in comments: user_name = item.select_one('.username').text.strip() post_time = item.select_one('.time').get('title') content = item.select_one('.content').text.strip() data.append({ "user": user_name, "timestamp": post_time, "message": content }) ``` #### 数据存储处理 最后一步就是将收集到的数据持久化保存至本地文件系统或其他形式的数据库中以便后续分析使用。 ```python import json with open('./douyin_comments.json', mode='w+', encoding='utf8') as f: json.dump(data, f, ensure_ascii=False, indent=2) ``` 关闭浏览器连接结束会话。 ```python driver.quit() ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值