Python中文
首页
教程
问答
标签
搜索
登录
注册
使用lyricsgenius包收集歌词的Python Twitter Bot
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在使用lyricsgenius python包(<a href="https://pypi.org/project/lyricsgenius/" rel="nofollow noreferrer">https://pypi.org/project/lyricsgenius/</a>)根据本教程制作一个Twitter歌词机器人-<a href="https://medium.com/@mahibhosain98/creating-a-lyrics-bot-on-twitter-with-python3-and-aws-lambda-1e22743dc3b7" rel="nofollow noreferrer">https://medium.com/@mahibhosain98/creating-a-lyrics-bot-on-twitter-with-python3-and-aws-lambda-1e22743dc3b7</a></p> <p>到目前为止,我的应用程序使用以下代码成功返回指定艺术家随机选择的歌曲的歌词:</p> <pre><code>all_songs = ["array_of_song_titles"] def get_raw_lyrics(): genius_client_access_token = "my_access_token" genius = lyricsgenius.Genius(genius_client_access_token) random_song_title = random.choice(all_songs) lyrics = genius.search_song(random_song_title, "Artist Name").lyrics song = random_song_title.upper() return lyrics, song lyrics, song = get_raw_lyrics() print(lyrics) </code></pre> <p>然而,当我打印歌词时,我可以看到,在最后一首歌词之后,它还从genius.com获取了“EmbedShare URLCopyEmbedCopy”</p> <p>例如,最后一行看起来像</p> <pre><code>'Dancing to electro-pop like a robot from 1984 Said, from 1984EmbedShare URLCopyEmbedCopy' </code></pre> <p>如何防止EmbedShare URLCopyEmbedCopy出现在最终歌词字符串中</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p><code>print(lyrics.replace("EmbedShare URLCopyEmbedCopy", ""))</code>是否适用于您的用例</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在PyObj中使用respondsToSelector和performSelector
1 回答
如何在pyobj中停止线程
4 回答
如何在pyobj中生成线程
3 回答
如何在pyodbc中为记录集指定游标类型?
2 回答
如何在pyodbc中从用户处获取表名,同时避免SQL注入?
5 回答
如何在pyodbc中使用executemany运行多个SELECT查询
10 回答
如何在pyodbc中同时在n个游标上并行运行n个进程?
1 回答
如何在pyodbc中控制连接池的大小?
9 回答
如何在pyodbc中自动调用fetchall()而不进行异常处理?
8 回答
如何在pyODBC查询中参数化日期戳?
8 回答
如何在pyodbc输出转换器函数中解压sqlserver DATETIME?
9 回答
如何在pyodb中安装所有驱动程序
8 回答
如何在pyodb嵌套循环中调用不同的查询
9 回答
如何在pyomo.environ公司modu装置
6 回答
如何在Pyomoconstraints中建模逻辑或量词
6 回答
如何在Pyomo中为约束使用数组
3 回答
如何在pyomo中使用集和范围集的多级索引?
4 回答
如何在PYOMO中分配伪二进制变量
6 回答
如何在Pyomo中创建OR约束?
9 回答
如何在Pyomo中动态地将变量添加到列表中?
6 回答