读写短文。
os-spage的Python项目详细描述
#操作系统SPAGE
[![构建状态](https://www.travis-ci.org/cfhamlet/os-spage.svg?branch=master)(https://www.travis-ci.org/cfhamlet/os spage)
[![codecov](https://codecov.io/gh/cfhamlet/os spage/branch/master/graph/badge.svg)(https://codecov.io/gh/cfhamlet/os spage)
[![pypi-python版本](https://img.shields.io/pypi/pyversions/os spage.svg)(https://pypi.python.org/pypi/os spage)
[![pypi](https://img.shields.io/pypi/v/os spage.svg)(https://pypi.python.org/pypi/os spage)
读写spage。
spage是一种不兼容的数据结构,用于指定获取的记录。一般来说,它包含四个子块:*url*、*inner庘header*、*http庘header*和*data*
spage:
-庘url庘:url。
-庘inner庘header庘:键值,可用于记录提取/处理信息,如提取时间、数据摘要、记录类型等。
-庘http庘header庘:键值,如您所知,服务器的响应http头。
-\u data\uuu:获取的数据,可以是平面的或压缩的html。
我们使用dict type来实现spage。可以使用预定义的[模式](https://github.com/cfhamlet/os-spage/blob/master/src/os_spage/default_schema.py)进行验证。
我们选择[os rotatefile]作为默认后端。
毕竟,所有数据都将以字符串(Unicode python2)的形式读取。
=--
offpage:
从v0.4开始,此libaray支持从offpage读取。offpage是另一种数据存储格式,包括url、headers和series数据。使用“read/open_file``方法”和“page\u type=“offpage”``方法可以从offpage中读取数据。
*写入大小旋转文件
url='http://www.google.com/http://www.google.com/http://www.google.com/http://www.google.com/www.com/
in内部
_header={'user-agent':'mozilla/5.0','batchid':'test'}
http嫒header={'content-type':'text/html'}
data=b“你好,世界!”
f=open_file('file','w',roll_size='1G',compress=True)
f.write(url,inner_header=inner_header,http_header=http_header,data=data,flush=True)
f.close()
``````
*从大小读取旋转文件
````
“r”)
f.read()中的记录:
print(record)
f.close()
````
*r/w与其他文件(如object
````
from io import bytesio
from os spage import read,write
s=bytesio()
write,“http://www.google.com/”
s.seek(0)
读取记录:
打印(记录)
````
[![构建状态](https://www.travis-ci.org/cfhamlet/os-spage.svg?branch=master)(https://www.travis-ci.org/cfhamlet/os spage)
[![codecov](https://codecov.io/gh/cfhamlet/os spage/branch/master/graph/badge.svg)(https://codecov.io/gh/cfhamlet/os spage)
[![pypi-python版本](https://img.shields.io/pypi/pyversions/os spage.svg)(https://pypi.python.org/pypi/os spage)
[![pypi](https://img.shields.io/pypi/v/os spage.svg)(https://pypi.python.org/pypi/os spage)
读写spage。
spage是一种不兼容的数据结构,用于指定获取的记录。一般来说,它包含四个子块:*url*、*inner庘header*、*http庘header*和*data*
spage:
-庘url庘:url。
-庘inner庘header庘:键值,可用于记录提取/处理信息,如提取时间、数据摘要、记录类型等。
-庘http庘header庘:键值,如您所知,服务器的响应http头。
-\u data\uuu:获取的数据,可以是平面的或压缩的html。
我们使用dict type来实现spage。可以使用预定义的[模式](https://github.com/cfhamlet/os-spage/blob/master/src/os_spage/default_schema.py)进行验证。
我们选择[os rotatefile]作为默认后端。
毕竟,所有数据都将以字符串(Unicode python2)的形式读取。
=--
offpage:
从v0.4开始,此libaray支持从offpage读取。offpage是另一种数据存储格式,包括url、headers和series数据。使用“read/open_file``方法”和“page\u type=“offpage”``方法可以从offpage中读取数据。
*写入大小旋转文件
url='http://www.google.com/http://www.google.com/http://www.google.com/http://www.google.com/www.com/
in内部
_header={'user-agent':'mozilla/5.0','batchid':'test'}
http嫒header={'content-type':'text/html'}
data=b“你好,世界!”
f=open_file('file','w',roll_size='1G',compress=True)
f.write(url,inner_header=inner_header,http_header=http_header,data=data,flush=True)
f.close()
``````
*从大小读取旋转文件
````
“r”)
f.read()中的记录:
print(record)
f.close()
````
*r/w与其他文件(如object
````
from io import bytesio
from os spage import read,write
s=bytesio()
write,“http://www.google.com/”
s.seek(0)
读取记录:
打印(记录)
````