Skip to main content

Python Implementation of SingleFile

Project description

概述

SingleFile的python实现

依赖

chrome浏览器
基于DrissionPage('4.0.4.21')进行修改,因此需要安装chrome

安装

pip install pySingleFile

使用示例

打印资源示例

from pySingleFile import SingleFile
u = "https://www.baidu.com/"
sf = SingleFile(u)
# 打印资源示例
sf.get_resource()

print("image资源有:")
for img in sf.images:
    print(img["url"])
    if img["content"]:
        print(img["content"][:20])
        print(img["data_uri"][:50])
        print("\n")

print("\n")
print("JavaScript资源有:")
for js in sf.javascripts:
    print(js["url"])
    if js["content"]:
        print(js["content"][:50])
        print(js["data_uri"][:50])
        print("\n")

print("\n")
print("CSS资源有:")
for css in sf.stylelinks:
    print(css["url"])
    if css["content"]:
        print(css["content"][:50])
        print(css["data_uri"][:50])
        print("\n")

result

image资源有:
https://pss.bdstatic.com/static/superman/img/topnav/newfanyi-da0cea8f7e.png
b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00X'
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgA

https://pss.bdstatic.com/static/superman/img/topnav/newxueshuicon-a5314d5c83.png
b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00X'
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgA


JavaScript资源有:
https://pss.bdstatic.com/static/superman/amd_modules/tslib-c95383af0c.js
define('tslib', [
    'require',
    'amd_modules/
data:text/javascript;base64,ZGVmaW5lKCd0c2xpYicsIF

https://hectorstatic.baidu.com/cd37ed75a9387c5b.js
(function(){ var _0x3c93=['SmlrTGY=','Z0xGUXQ=','b
data:text/javascript;base64,KGZ1bmN0aW9uKCl7IHZhci



CSS资源有:
https://pss.bdstatic.com/r/www/static/font/cosmic/pc/cos-icon_99f656e.css
@font-face {
    font-family: "cos-icon"; /* Proje
data:text/css;base64,QGZvbnQtZmFjZSB7CiAgICBmb250L

https://pss.bdstatic.com/static/superman/css/ubase_sync-d600f57804.css?v=md5
.sui-scrollbar-container{position:relative;overflo
data:text/css;base64,LnN1aS1zY3JvbGxiYXItY29udGFpb

离线保存示例

from pySingleFile import SingleFile
u = "https://www.baidu.com/"
sf = SingleFile(u)
#  离线保存示例
sf.save()

result

文件保存为:百度一下,你就知道.html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pySingleFile-0.1.4.tar.gz (134.3 kB view details)

Uploaded Source

Built Distribution

pySingleFile-0.1.4-py3-none-any.whl (180.8 kB view details)

Uploaded Python 3

File details

Details for the file pySingleFile-0.1.4.tar.gz.

File metadata

  • Download URL: pySingleFile-0.1.4.tar.gz
  • Upload date:
  • Size: 134.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.5

File hashes

Hashes for pySingleFile-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a09a46b273ef7032dfec06bced4cc73843423ccb5ece9089df856a5265ff2cc2
MD5 4f0e078a09a7f63f7c6811046fc15c09
BLAKE2b-256 d96956250f1163a2da937f12589383dba178a52a0812e48525b0741d6fa993ee

See more details on using hashes here.

File details

Details for the file pySingleFile-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pySingleFile-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ac57d1c19df5fab029daf5e164f5d3ec3b9092813f64f731b984c4769aa8f0fb
MD5 bfb26678151cab3331eebd4a037ed896
BLAKE2b-256 033ef19e38d1d0fbc093678688681aa333ca960fa7fc9aa54f9a8d090091e5a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page