html table extractor,GitHub - Meshate/html-table-extractor: extract data from html table

HTML Table Extractor

68747470733a2f2f7472617669732d63692e6f72672f7975616e78752d6c692f68746d6c2d7461626c652d657874726163746f722e7376673f6272616e63683d6d6173746572

HTML Table Extractor is a python library that uses Beautiful Soup to extract data from complicated and messy html table

Important links

Installation

pip install 'beautifulsoup4==4.5.3'

pip install html-table-extractor

Usage

Example 1 - Simple

12

34

from html_table_extractor.extractor import Extractor

table_doc = """

12
34

"""

extractor = Extractor(table_doc)

extractor.parse()

extractor.return_list()

It will print out:

[[u'1', u'2'], [u'3', u'4']]

Example 2 - Transformer

12

34

from html_table_extractor.extractor import Extractor

table_doc = """

12
34

"""

extractor = Extractor(table_doc, transformer=int)

extractor.parse()

extractor.return_list()

It will print out:

[[1, 2], [3, 4]]

Example 3 - Pass BS4 Tag

12

34

from html_table_extractor.extractor import Extractor

from bs4 import BeautifulSoup

table_doc = """

12
34
not wanted

"""

soup = BeautifulSoup(table_doc, 'html.parser')

extractor = Extractor(soup, id_='wanted')

extractor.parse()

extractor.return_list()

It will print out:

[[u'1', u'2'], [u'3', u'4']]

Example 4 - Complex

1

2

3

4

5

from html_table_extractor.extractor import Extractor

table_doc = """

123
4
5

"""

extractor = Extractor(table_doc)

extractor.parse()

extractor.return_list()

It will print out:

[[u'1', u'2', u'3'], [u'1', u'4', u'4'], [u'5', u'5', u'5']]

Example 5 - Conflicted

1

2

3

4

5

from html_table_extractor.extractor import Extractor

table_doc = """

123
4
5

"""

extractor = Extractor(table_doc)

extractor.parse()

extractor.return_list()

It will print out:

[[u'1', u'2', u'3'], [u'1', u'4', u'3'], [u'5', u'5', u'3']]

Example 6 - Write to file

12

34

from html_table_extractor.extractor import Extractor

table_doc = """

12
34

"""

extractor = Extractor(table_doc).parse()

extractor.write_to_csv(path='.')

It will write to a given path and create a new csv file called output.csv:

1,2

3,4

Team

Errors/ Bugs

If something is not working correctly, or if you have any suggestion on improvements, report it here

Copyright

Copyright (c) 2017 Justin Li. Released under the MIT License

Third-party copyright in this distribution is noted where applicable.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个仓库中的 `DeepMarks.py` 文件是一个综合性的脚本,用于实现数字水印的嵌入和提取功能。具体来说,这个脚本会调用 `topology.py` 中定义的神经网络模型,将水印编码嵌入到图像中,然后从嵌入了水印的图像中提取出水印编码。 下面是 `DeepMarks.py` 的主要实现流程: 1. 导入必要的库和模块 脚本首先导入了必要的库和模块,比如 PyTorch 库、NumPy 库、argparse 库等。 2. 定义命令行参数 脚本使用 `argparse` 库定义了一些命令行参数,比如 `--image_path`、`--watermark_path`、`--output_path`、`--mode` 等。这些参数用于指定输入图像、水印、输出路径和运行模式。 3. 加载模型 脚本调用 `topology.py` 中的 `Extractor()` 和 `Embedder()` 类,分别构建水印提取和嵌入模型。 4. 加载图像和水印 脚本调用 `image.py` 中的 `load_image()` 和 `save_image()` 函数,分别加载和保存图像。同时,脚本调用 `watermark.py` 中的 `load_watermark()` 函数,加载水印。 5. 将水印嵌入到图像中 如果 `mode` 参数为 `embed`,脚本会将水印编码嵌入到图像的 DCT 系数中,并且将嵌入了水印的图像保存到指定路径下。 6. 从图像中提取水印 如果 `mode` 参数为 `extract`,脚本会从嵌入了水印的图像中提取出水印编码,并且将编码保存到指定路径下。 总体来说,`DeepMarks.py` 是一个综合性的脚本,用于数字水印的嵌入和提取功能。它调用了 `topology.py` 中定义的神经网络模型,可以有效地进行数字水印的处理。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值