一个Python库,用于从SCP wiki中获取数据。

scpscraper的Python项目详细描述


SCP刮板

一个小的Python库,用于从SCP wiki中获取数据。考虑到人工智能培训(即NLP模型)和数据集收集(用于外部项目scp的分类),并且有一些参数允许在这些应用程序中易于使用。在

下面是安装说明、如何使用此库的示例以及如何使用它的方法。我希望你能发现这个和我一样有用!在

示例代码

安装

scpscraper可以通过pip install安装。下面是我建议使用的命令,这样您就可以一直使用最新版本。在

pip3 install --upgrade scpscraper

基础知识

导入库

^{pr2}$

获取SCP的名称

# Let's use 3001 (Red Reality) as an example.name=scpscraper.get_scp_name(3001)print(name)# Outputs "Red Reality"

尽可能多地获取有关SCP的详细信息

# Again using 3001 as an exampleinfo=scpscraper.get_scp(3001)print(info)# Outputs a dictionary with the# name, object id, rating, page content by section, etc.

有趣的东西

获取SCP的page-contentdiv HTML

作为参考,page-contentdiv包含了用户实际编写的内容,没有所有额外的Wikidot外部内容。在

# Once again, 3001 is the examplescp=scpscraper.get_single_scp(3001)# Grab the page-content div specificallycontent=scp.find_all('div',id='page-content')print(content)# Outputs "<div id="page-content"> ... </div>"

multiplescp抓取HTML或信息

# Grab info on SCPs 000-099scpscraper.scrape_scps(0,100)# Same as above, but only grabbing Keter-class SCPsscpscraper.scrape_scps(0,100,tags=['keter'])# Grab 000-099 in a format that can be used to train AIscpscraper.scrape_scps(0,100,ai_dataset=True)
# Scrape the page-content div's HTML from SCP-000 to SCP-099# Only including this as an example, but scrape_scps_html() has# all the same options as scrape_scps().scpscraper.scrape_scps_html(0,100)

谷歌Colaboratory仅限使用

因为googlecolaboratory中包含了google.colab模块,我们可以在那里做一些其他我们不能做的事情。在

将你的Google驱动器安装到Colaboratory虚拟机上

# Mounts it to the directory /content/drive/scpscraper.gdrive.mount()

抓取SCP info/HTML,然后复制到您的Google驱动器中

# Requires your Google Drive to be mounted at the directory /content/drive/scpscraper.scrape_scps(0,100,copy_to_drive=True)scpscraper.scrape_scps_html(0,100,copy_to_drive=True)

将其他文件复制到/来自您的Google Drive

# Requires your Google Drive to be mounted at the directory /content/drive/scpscraper.gdrive.copy_to_drive('example.txt')scpscraper.gdrive.copy_from_drive('example.txt')

计划的更新

未来可能会进行更新,使从任何网站抓取数据变得容易/可行,从而便于大量收集数据。在

链接到GitHub Repo

请考虑检查一下!您可以在GitHub Repo中报告问题、请求特性、为该项目贡献等。这是联系我了解与本项目有关的问题/反馈的最佳方式。在

https://github.com/JaonHax/scpscraper/

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
ApachePOI如何通过java从excel文件中删除空白列?   linux到后台Java服务应用程序的简单发送/接收接口   java ActionBarPullToRefresh什么都没发生   java从millis获取错误的整数天   java相同的代码在两个不同的包上表现不同   java将每个新的char元素写入一个文件(如果被覆盖)   mysql如何在Java中通过外键链接的多个表中插入数据   java环境下mysql网络文件访问   java当使用构建器模式时,为什么我不应该重用builderobject来访问对象配置?   java jQueryServlet post异常失败   java应该使用什么逻辑来创建像《愤怒的小鸟》中那样的锁屏   java Android:在不滑动的情况下更改ViewPager中的片段   java在使用我的程序逻辑时获得空输出