当前位置: 首页 > news >正文

做网站犯法网站关键词推广优化

做网站犯法,网站关键词推广优化,养老网站备案必须做前置审批吗,网站规划模板下载pdfplumber简介 Pdfplumber是一个可以处理pdf格式信息的库。可以查找关于每个文本字符、矩阵、和行的详细信息,也可以对表格进行提取并进行可视化调试。 文档参考https://github.com/jsvine/pdfplumber pdfplumber安装 安装直接采用pip即可。命令行中输入 pip insta…

pdfplumber简介

Pdfplumber是一个可以处理pdf格式信息的库。可以查找关于每个文本字符、矩阵、和行的详细信息,也可以对表格进行提取并进行可视化调试。

文档参考https://github.com/jsvine/pdfplumber

pdfplumber安装

安装直接采用pip即可。命令行中输入

pip install pdfplumber

如果要进行可视化的调试,则需要安装ImageMagick。
Pdfplumber GitHub: https://github.com/jsvine/pdfplumber
ImageMagick地址:
http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-windows
(官网地址没有6x, 6x地址:https://imagemagick.org/download/binaries/)

(注意:我在装ImageMagick,使用起来是报错了, 网上参照了这里 了解到应该装6x版,7x版会报错。故找了6x的地址如上。)

在使用to_image函数输出图片时,如果报错DelegateException。则安装GhostScript 32位。(注意,一定要下载32位版本,哪怕Windows和python的版本是64位的。)
GhostScript: https://www.ghostscript.com/download/gsdnld.html

 

简单使用

import pdfplumber
with pdfplumber.open("path/file.pdf") as pdf:first_page = pdf.pages[0]  #获取第一页print(first_page.chars[0])

pdfplumber.pdf中包含了.metadata和.pages两个属性。
metadata是一个包含pdf信息的字典。
pages是一个包含页面信息的列表。

每个pdfplumber.page的类中包含了几个主要的属性。
page_number 页码
width 页面宽度
height 页面高度
objects/.chars/.lines/.rects 这些属性中每一个都是一个列表,每个列表都包含一个字典,每个字典用于说明页面中的对象信息, 包括直线,字符, 方格等位置信息。

 

常用方法

extract_text() 用来提页面中的文本,将页面的所有字符对象整理为的那个字符串
extract_words() 返回的是所有的单词及其相关信息
extract_tables() 提取页面的表格
to_image() 用于可视化调试时,返回PageImage类的一个实例

 

常用参数

table_settings

表提取设置

默认情况下,extract_tables使用页面的垂直和水平线(或矩形边)作为单元格分隔符。但是方法该可以通过table_settings参数高度定制。可能的设置及其默认值:

{"vertical_strategy": "lines", "horizontal_strategy": "lines","explicit_vertical_lines": [],"explicit_horizontal_lines": [],"snap_tolerance": 3,"join_tolerance": 3,"edge_min_length": 3,"min_words_vertical": 3,"min_words_horizontal": 1,"keep_blank_chars": False,"text_tolerance": 3,"text_x_tolerance": None,"text_y_tolerance": None,"intersection_tolerance": 3,"intersection_x_tolerance": None,"intersection_y_tolerance": None,
}

表提取策略

vertical_strategy 和 horizontal_strategy 的参数选项 

"lines"Use the page's graphical lines — including the sides of rectangle objects — as the borders of potential table-cells.
"lines_strict"Use the page's graphical lines — but not the sides of rectangle objects — as the borders of potential table-cells.
"text"For vertical_strategy: Deduce the (imaginary) lines that connect the left, right, or center of words on the page, and use those lines as the borders of potential table-cells. For horizontal_strategy, the same but using the tops of words.
"explicit"Only use the lines explicitly defined in explicit_vertical_lines / explicit_horizontal_lines.
 

举例使用

读取文字

import pdfplumber
import pandas as pdwith pdfplumber.open("E:\\600aaa_2.pdf") as pdf:page_count = len(pdf.pages)print(page_count)  # 得到页数for page in pdf.pages:print('---------- 第[%d]页 ----------' % page.page_number)# 获取当前页面的全部文本信息,包括表格中的文字print(page.extract_text())

 读取表格

import pdfplumber
import pandas as pd
import rewith pdfplumber.open("E:\\600aaa_1.pdf") as pdf:page_count = len(pdf.pages)print(page_count)  # 得到页数for page in pdf.pages:print('---------- 第[%d]页 ----------' % page.page_number)for pdf_table in page.extract_tables(table_settings={"vertical_strategy": "text","horizontal_strategy": "lines","intersection_tolerance":20}): # 边缘相交合并单元格大小# print(pdf_table)for row in pdf_table:# 去掉回车换行print([re.sub('\s+', '', cell) if cell is not None else None for cell in row])

 

 

 

部分参照:https://blog.csdn.net/Elaine_jm/article/details/84841233

 

转载于:https://www.cnblogs.com/xiao-apple36/p/10496707.html

http://www.lbrq.cn/news/2717173.html

相关文章:

  • 个人怎么做网站优化aso优化什么意思
  • 网站的彩色标签怎么做的网站搭建工具
  • 做动画 的 网站有哪些软件下载产品推销
  • 中国农村建设投资有限公司网站首页广州四楚seo顾问
  • 什么叫模板网站西安网站设计公司
  • wordpress后台管理界面地址网站优化seo
  • 北京软件外包公司排行榜汕头seo排名公司
  • 网站可信图标官网seo优化
  • 用什么软件做网站图片百度蜘蛛池自动收录seo
  • 制作一个学校门户网站沈阳优化推广哪家好
  • 猫眼网站建设北京网站制作建设公司
  • wordpress商店单页windows优化大师官方网站
  • 网站建设开发协议拼多多搜索关键词排名
  • 做律师推广的网站有哪些朝阳区seo
  • 怎么做优化网站排名南京seo网站优化推广
  • 服务好的南京网站建设程序员培训机构排名
  • 网站建设费用价格明细表网站建设网络推广seo
  • 做网站 怎么做留言seo公司是什么意思
  • 易语言 wordpressseo搜索引擎优化工程师招聘
  • 哪里有做网站设计青岛百度网站排名优化
  • 银川网站设计公司网络推广预算方案
  • 垂直类门户网站重庆seo排名扣费
  • 乌鲁木齐外贸网页设计培训西安百度快照优化
  • 网站建设服装项目设计书搜索引擎优化作业
  • 品牌网站建设小7蝌蚪alexa排名
  • 青岛做网站方案如何把网站推广
  • 网站开发论文范文高权重网站出售
  • ps怎么做电商网站微信公众号推广方法有哪些
  • 摩托车专业网站腾讯广点通
  • 最便宜的网站建设广州seo网站开发
  • 【Docker】openEuler 使用docker-compose部署gitlab-ce
  • 嵌入式第二十八天(程序与进程)
  • 苹果正计划大举进军人工智能硬件领域
  • 比特币与区块链:去中心化的技术革命
  • Java毕业设计选题推荐 |基于SpringBoot的水产养殖管理系统 智能水产养殖监测系统 水产养殖小程序
  • 北京JAVA基础面试30天打卡09