Initial commit
This commit is contained in:
1
venv/lib/python3.7/__future__.py
Symbolic link
1
venv/lib/python3.7/__future__.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/__future__.py
|
||||
BIN
venv/lib/python3.7/__pycache__/__future__.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/__future__.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/_bootlocale.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/_bootlocale.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/_collections_abc.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/_collections_abc.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/_weakrefset.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/_weakrefset.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/abc.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/abc.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/base64.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/base64.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/bisect.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/bisect.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/codecs.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/codecs.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/copy.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/copy.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/copyreg.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/copyreg.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/enum.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/enum.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/fnmatch.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/fnmatch.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/functools.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/functools.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/genericpath.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/genericpath.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/hashlib.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/hashlib.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/heapq.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/heapq.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/hmac.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/hmac.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/imp.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/imp.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/io.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/io.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/keyword.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/keyword.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/linecache.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/linecache.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/locale.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/locale.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/ntpath.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/ntpath.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/operator.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/operator.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/os.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/os.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/posixpath.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/posixpath.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/random.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/random.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/re.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/re.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/reprlib.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/reprlib.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/rlcompleter.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/rlcompleter.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/shutil.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/shutil.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/site.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/site.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/sre_compile.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/sre_compile.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/sre_constants.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/sre_constants.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/sre_parse.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/sre_parse.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/stat.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/stat.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/struct.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/struct.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/tarfile.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/tarfile.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/tempfile.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/tempfile.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/token.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/token.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/tokenize.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/tokenize.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/types.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/types.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/warnings.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/warnings.cpython-37.pyc
Normal file
Binary file not shown.
BIN
venv/lib/python3.7/__pycache__/weakref.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/__pycache__/weakref.cpython-37.pyc
Normal file
Binary file not shown.
1
venv/lib/python3.7/_bootlocale.py
Symbolic link
1
venv/lib/python3.7/_bootlocale.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/_bootlocale.py
|
||||
1
venv/lib/python3.7/_collections_abc.py
Symbolic link
1
venv/lib/python3.7/_collections_abc.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/_collections_abc.py
|
||||
1
venv/lib/python3.7/_dummy_thread.py
Symbolic link
1
venv/lib/python3.7/_dummy_thread.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/_dummy_thread.py
|
||||
1
venv/lib/python3.7/_weakrefset.py
Symbolic link
1
venv/lib/python3.7/_weakrefset.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/_weakrefset.py
|
||||
1
venv/lib/python3.7/abc.py
Symbolic link
1
venv/lib/python3.7/abc.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/abc.py
|
||||
1
venv/lib/python3.7/base64.py
Symbolic link
1
venv/lib/python3.7/base64.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/base64.py
|
||||
1
venv/lib/python3.7/bisect.py
Symbolic link
1
venv/lib/python3.7/bisect.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/bisect.py
|
||||
1
venv/lib/python3.7/codecs.py
Symbolic link
1
venv/lib/python3.7/codecs.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/codecs.py
|
||||
1
venv/lib/python3.7/collections
Symbolic link
1
venv/lib/python3.7/collections
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/collections
|
||||
1
venv/lib/python3.7/config-3.7m-x86_64-linux-gnu
Symbolic link
1
venv/lib/python3.7/config-3.7m-x86_64-linux-gnu
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu
|
||||
1
venv/lib/python3.7/copy.py
Symbolic link
1
venv/lib/python3.7/copy.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/copy.py
|
||||
1
venv/lib/python3.7/copyreg.py
Symbolic link
1
venv/lib/python3.7/copyreg.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/copyreg.py
|
||||
116
venv/lib/python3.7/distutils/__init__.py
Normal file
116
venv/lib/python3.7/distutils/__init__.py
Normal file
@@ -0,0 +1,116 @@
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
# opcode is not a virtualenv module, so we can use it to find the stdlib
|
||||
# Important! To work on pypy, this must be a module that resides in the
|
||||
# lib-python/modified-x.y.z directory
|
||||
import opcode
|
||||
|
||||
dirname = os.path.dirname
|
||||
|
||||
distutils_path = os.path.join(os.path.dirname(opcode.__file__), "distutils")
|
||||
if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)):
|
||||
warnings.warn("The virtualenv distutils package at %s appears to be in the same location as the system distutils?")
|
||||
else:
|
||||
__path__.insert(0, distutils_path) # noqa: F821
|
||||
real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ("", "", imp.PKG_DIRECTORY))
|
||||
# Copy the relevant attributes
|
||||
try:
|
||||
__revision__ = real_distutils.__revision__
|
||||
except AttributeError:
|
||||
pass
|
||||
__version__ = real_distutils.__version__
|
||||
|
||||
from distutils import dist, sysconfig # isort:skip
|
||||
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
basestring = str
|
||||
|
||||
# patch build_ext (distutils doesn't know how to get the libs directory
|
||||
# path on windows - it hardcodes the paths around the patched sys.prefix)
|
||||
|
||||
if sys.platform == "win32":
|
||||
from distutils.command.build_ext import build_ext as old_build_ext
|
||||
|
||||
class build_ext(old_build_ext):
|
||||
def finalize_options(self):
|
||||
if self.library_dirs is None:
|
||||
self.library_dirs = []
|
||||
elif isinstance(self.library_dirs, basestring):
|
||||
self.library_dirs = self.library_dirs.split(os.pathsep)
|
||||
|
||||
self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs"))
|
||||
old_build_ext.finalize_options(self)
|
||||
|
||||
from distutils.command import build_ext as build_ext_module
|
||||
|
||||
build_ext_module.build_ext = build_ext
|
||||
|
||||
# distutils.dist patches:
|
||||
|
||||
old_find_config_files = dist.Distribution.find_config_files
|
||||
|
||||
|
||||
def find_config_files(self):
|
||||
found = old_find_config_files(self)
|
||||
if os.name == "posix":
|
||||
user_filename = ".pydistutils.cfg"
|
||||
else:
|
||||
user_filename = "pydistutils.cfg"
|
||||
user_filename = os.path.join(sys.prefix, user_filename)
|
||||
if os.path.isfile(user_filename):
|
||||
for item in list(found):
|
||||
if item.endswith("pydistutils.cfg"):
|
||||
found.remove(item)
|
||||
found.append(user_filename)
|
||||
return found
|
||||
|
||||
|
||||
dist.Distribution.find_config_files = find_config_files
|
||||
|
||||
# distutils.sysconfig patches:
|
||||
|
||||
old_get_python_inc = sysconfig.get_python_inc
|
||||
|
||||
|
||||
def sysconfig_get_python_inc(plat_specific=0, prefix=None):
|
||||
if prefix is None:
|
||||
prefix = sys.real_prefix
|
||||
return old_get_python_inc(plat_specific, prefix)
|
||||
|
||||
|
||||
sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__
|
||||
sysconfig.get_python_inc = sysconfig_get_python_inc
|
||||
|
||||
old_get_python_lib = sysconfig.get_python_lib
|
||||
|
||||
|
||||
def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
|
||||
if standard_lib and prefix is None:
|
||||
prefix = sys.real_prefix
|
||||
return old_get_python_lib(plat_specific, standard_lib, prefix)
|
||||
|
||||
|
||||
sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__
|
||||
sysconfig.get_python_lib = sysconfig_get_python_lib
|
||||
|
||||
old_get_config_vars = sysconfig.get_config_vars
|
||||
|
||||
|
||||
def sysconfig_get_config_vars(*args):
|
||||
real_vars = old_get_config_vars(*args)
|
||||
if sys.platform == "win32":
|
||||
lib_dir = os.path.join(sys.real_prefix, "libs")
|
||||
if isinstance(real_vars, dict) and "LIBDIR" not in real_vars:
|
||||
real_vars["LIBDIR"] = lib_dir # asked for all
|
||||
elif isinstance(real_vars, list) and "LIBDIR" in args:
|
||||
real_vars = real_vars + [lib_dir] # asked for list
|
||||
return real_vars
|
||||
|
||||
|
||||
sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__
|
||||
sysconfig.get_config_vars = sysconfig_get_config_vars
|
||||
BIN
venv/lib/python3.7/distutils/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/distutils/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
6
venv/lib/python3.7/distutils/distutils.cfg
Normal file
6
venv/lib/python3.7/distutils/distutils.cfg
Normal file
@@ -0,0 +1,6 @@
|
||||
# This is a config file local to this virtualenv installation
|
||||
# You may include options that will be used by all distutils commands,
|
||||
# and by easy_install. For instance:
|
||||
#
|
||||
# [easy_install]
|
||||
# find_links = http://mylocalsite
|
||||
1
venv/lib/python3.7/encodings
Symbolic link
1
venv/lib/python3.7/encodings
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/encodings
|
||||
1
venv/lib/python3.7/enum.py
Symbolic link
1
venv/lib/python3.7/enum.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/enum.py
|
||||
1
venv/lib/python3.7/fnmatch.py
Symbolic link
1
venv/lib/python3.7/fnmatch.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/fnmatch.py
|
||||
1
venv/lib/python3.7/functools.py
Symbolic link
1
venv/lib/python3.7/functools.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/functools.py
|
||||
1
venv/lib/python3.7/genericpath.py
Symbolic link
1
venv/lib/python3.7/genericpath.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/genericpath.py
|
||||
1
venv/lib/python3.7/hashlib.py
Symbolic link
1
venv/lib/python3.7/hashlib.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/hashlib.py
|
||||
1
venv/lib/python3.7/heapq.py
Symbolic link
1
venv/lib/python3.7/heapq.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/heapq.py
|
||||
1
venv/lib/python3.7/hmac.py
Symbolic link
1
venv/lib/python3.7/hmac.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/hmac.py
|
||||
1
venv/lib/python3.7/imp.py
Symbolic link
1
venv/lib/python3.7/imp.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/imp.py
|
||||
1
venv/lib/python3.7/importlib
Symbolic link
1
venv/lib/python3.7/importlib
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/importlib
|
||||
1
venv/lib/python3.7/io.py
Symbolic link
1
venv/lib/python3.7/io.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/io.py
|
||||
1
venv/lib/python3.7/keyword.py
Symbolic link
1
venv/lib/python3.7/keyword.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/keyword.py
|
||||
1
venv/lib/python3.7/lib-dynload
Symbolic link
1
venv/lib/python3.7/lib-dynload
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/lib-dynload
|
||||
1
venv/lib/python3.7/linecache.py
Symbolic link
1
venv/lib/python3.7/linecache.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/linecache.py
|
||||
1
venv/lib/python3.7/locale.py
Symbolic link
1
venv/lib/python3.7/locale.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/locale.py
|
||||
0
venv/lib/python3.7/no-global-site-packages.txt
Normal file
0
venv/lib/python3.7/no-global-site-packages.txt
Normal file
1
venv/lib/python3.7/ntpath.py
Symbolic link
1
venv/lib/python3.7/ntpath.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/ntpath.py
|
||||
1
venv/lib/python3.7/operator.py
Symbolic link
1
venv/lib/python3.7/operator.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/operator.py
|
||||
1
venv/lib/python3.7/orig-prefix.txt
Normal file
1
venv/lib/python3.7/orig-prefix.txt
Normal file
@@ -0,0 +1 @@
|
||||
/usr
|
||||
1
venv/lib/python3.7/os.py
Symbolic link
1
venv/lib/python3.7/os.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/os.py
|
||||
1
venv/lib/python3.7/posixpath.py
Symbolic link
1
venv/lib/python3.7/posixpath.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/posixpath.py
|
||||
1
venv/lib/python3.7/random.py
Symbolic link
1
venv/lib/python3.7/random.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/random.py
|
||||
1
venv/lib/python3.7/re.py
Symbolic link
1
venv/lib/python3.7/re.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/re.py
|
||||
1
venv/lib/python3.7/reprlib.py
Symbolic link
1
venv/lib/python3.7/reprlib.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/reprlib.py
|
||||
1
venv/lib/python3.7/rlcompleter.py
Symbolic link
1
venv/lib/python3.7/rlcompleter.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/rlcompleter.py
|
||||
1
venv/lib/python3.7/shutil.py
Symbolic link
1
venv/lib/python3.7/shutil.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/lib/python3.7/shutil.py
|
||||
Binary file not shown.
BIN
venv/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc
Normal file
BIN
venv/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc
Normal file
Binary file not shown.
@@ -0,0 +1,104 @@
|
||||
Beautiful Soup is a library that makes it easy to scrape information
|
||||
from web pages. It sits atop an HTML or XML parser, providing Pythonic
|
||||
idioms for iterating, searching, and modifying the parse tree.
|
||||
|
||||
# Quick start
|
||||
|
||||
```
|
||||
>>> from bs4 import BeautifulSoup
|
||||
>>> soup = BeautifulSoup("<p>Some<b>bad<i>HTML")
|
||||
>>> print soup.prettify()
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Some
|
||||
<b>
|
||||
bad
|
||||
<i>
|
||||
HTML
|
||||
</i>
|
||||
</b>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
>>> soup.find(text="bad")
|
||||
u'bad'
|
||||
>>> soup.i
|
||||
<i>HTML</i>
|
||||
#
|
||||
>>> soup = BeautifulSoup("<tag1>Some<tag2/>bad<tag3>XML", "xml")
|
||||
#
|
||||
>>> print soup.prettify()
|
||||
<?xml version="1.0" encoding="utf-8">
|
||||
<tag1>
|
||||
Some
|
||||
<tag2 />
|
||||
bad
|
||||
<tag3>
|
||||
XML
|
||||
</tag3>
|
||||
</tag1>
|
||||
```
|
||||
|
||||
To go beyond the basics, [comprehensive documentation is available](http://www.crummy.com/software/BeautifulSoup/bs4/doc/).
|
||||
|
||||
# Links
|
||||
|
||||
* [Homepage](http://www.crummy.com/software/BeautifulSoup/bs4/)
|
||||
* [Documentation](http://www.crummy.com/software/BeautifulSoup/bs4/doc/)
|
||||
* [Discussion group](http://groups.google.com/group/beautifulsoup/)
|
||||
* [Development](https://code.launchpad.net/beautifulsoup/)
|
||||
* [Bug tracker](https://bugs.launchpad.net/beautifulsoup/)
|
||||
* [Complete changelog](https://bazaar.launchpad.net/~leonardr/beautifulsoup/bs4/view/head:/CHANGELOG)
|
||||
|
||||
# Note on Python 2 sunsetting
|
||||
|
||||
Since 2012, Beautiful Soup has been developed as a Python 2 library
|
||||
which is automatically converted to Python 3 code as necessary. This
|
||||
makes it impossible to take advantages of some features of Python
|
||||
3.
|
||||
|
||||
For this reason, I plan to discontinue Beautiful Soup's Python 2
|
||||
support at some point after January 1, 2021: one year after the sunset
|
||||
date for Python 2 itself. Beyond that point, new Beautiful Soup
|
||||
development will exclusively target Python 3. Of course, older
|
||||
releases of Beautiful Soup, which support both versions, will continue
|
||||
to be available.
|
||||
|
||||
# Supporting the project
|
||||
|
||||
If you use Beautiful Soup as part of your professional work, please consider a
|
||||
[Tidelift subscription](https://tidelift.com/subscription/pkg/pypi-beautifulsoup4?utm_source=pypi-beautifulsoup4&utm_medium=referral&utm_campaign=readme).
|
||||
This will support many of the free software projects your organization
|
||||
depends on, not just Beautiful Soup.
|
||||
|
||||
If you use Beautiful Soup for personal projects, the best way to say
|
||||
thank you is to read
|
||||
[Tool Safety](https://www.crummy.com/software/BeautifulSoup/zine/), a zine I
|
||||
wrote about what Beautiful Soup has taught me about software
|
||||
development.
|
||||
|
||||
# Building the documentation
|
||||
|
||||
The bs4/doc/ directory contains full documentation in Sphinx
|
||||
format. Run `make html` in that directory to create HTML
|
||||
documentation.
|
||||
|
||||
# Running the unit tests
|
||||
|
||||
Beautiful Soup supports unit test discovery from the project root directory:
|
||||
|
||||
```
|
||||
$ nosetests
|
||||
```
|
||||
|
||||
```
|
||||
$ python -m unittest discover -s bs4
|
||||
```
|
||||
|
||||
If you checked out the source tree, you should see a script in the
|
||||
home directory called test-all-versions. This script will run the unit
|
||||
tests under Python 2, then create a temporary Python 3 conversion of
|
||||
the source and run the unit tests again under Python 3.
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,130 @@
|
||||
Metadata-Version: 2.0
|
||||
Name: beautifulsoup4
|
||||
Version: 4.8.1
|
||||
Summary: Screen-scraping library
|
||||
Home-page: http://www.crummy.com/software/BeautifulSoup/bs4/
|
||||
Author: Leonard Richardson
|
||||
Author-email: leonardr@segfault.org
|
||||
License: MIT
|
||||
Download-URL: http://www.crummy.com/software/BeautifulSoup/bs4/download/
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Topic :: Text Processing :: Markup :: HTML
|
||||
Classifier: Topic :: Text Processing :: Markup :: XML
|
||||
Classifier: Topic :: Text Processing :: Markup :: SGML
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Requires-Dist: soupsieve (>=1.2)
|
||||
Provides-Extra: html5lib
|
||||
Requires-Dist: html5lib; extra == 'html5lib'
|
||||
Provides-Extra: lxml
|
||||
Requires-Dist: lxml; extra == 'lxml'
|
||||
|
||||
Beautiful Soup is a library that makes it easy to scrape information
|
||||
from web pages. It sits atop an HTML or XML parser, providing Pythonic
|
||||
idioms for iterating, searching, and modifying the parse tree.
|
||||
|
||||
# Quick start
|
||||
|
||||
```
|
||||
>>> from bs4 import BeautifulSoup
|
||||
>>> soup = BeautifulSoup("<p>Some<b>bad<i>HTML")
|
||||
>>> print soup.prettify()
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Some
|
||||
<b>
|
||||
bad
|
||||
<i>
|
||||
HTML
|
||||
</i>
|
||||
</b>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
>>> soup.find(text="bad")
|
||||
u'bad'
|
||||
>>> soup.i
|
||||
<i>HTML</i>
|
||||
#
|
||||
>>> soup = BeautifulSoup("<tag1>Some<tag2/>bad<tag3>XML", "xml")
|
||||
#
|
||||
>>> print soup.prettify()
|
||||
<?xml version="1.0" encoding="utf-8">
|
||||
<tag1>
|
||||
Some
|
||||
<tag2 />
|
||||
bad
|
||||
<tag3>
|
||||
XML
|
||||
</tag3>
|
||||
</tag1>
|
||||
```
|
||||
|
||||
To go beyond the basics, [comprehensive documentation is available](http://www.crummy.com/software/BeautifulSoup/bs4/doc/).
|
||||
|
||||
# Links
|
||||
|
||||
* [Homepage](http://www.crummy.com/software/BeautifulSoup/bs4/)
|
||||
* [Documentation](http://www.crummy.com/software/BeautifulSoup/bs4/doc/)
|
||||
* [Discussion group](http://groups.google.com/group/beautifulsoup/)
|
||||
* [Development](https://code.launchpad.net/beautifulsoup/)
|
||||
* [Bug tracker](https://bugs.launchpad.net/beautifulsoup/)
|
||||
* [Complete changelog](https://bazaar.launchpad.net/~leonardr/beautifulsoup/bs4/view/head:/CHANGELOG)
|
||||
|
||||
# Note on Python 2 sunsetting
|
||||
|
||||
Since 2012, Beautiful Soup has been developed as a Python 2 library
|
||||
which is automatically converted to Python 3 code as necessary. This
|
||||
makes it impossible to take advantages of some features of Python
|
||||
3.
|
||||
|
||||
For this reason, I plan to discontinue Beautiful Soup's Python 2
|
||||
support at some point after January 1, 2021: one year after the sunset
|
||||
date for Python 2 itself. Beyond that point, new Beautiful Soup
|
||||
development will exclusively target Python 3. Of course, older
|
||||
releases of Beautiful Soup, which support both versions, will continue
|
||||
to be available.
|
||||
|
||||
# Supporting the project
|
||||
|
||||
If you use Beautiful Soup as part of your professional work, please consider a
|
||||
[Tidelift subscription](https://tidelift.com/subscription/pkg/pypi-beautifulsoup4?utm_source=pypi-beautifulsoup4&utm_medium=referral&utm_campaign=readme).
|
||||
This will support many of the free software projects your organization
|
||||
depends on, not just Beautiful Soup.
|
||||
|
||||
If you use Beautiful Soup for personal projects, the best way to say
|
||||
thank you is to read
|
||||
[Tool Safety](https://www.crummy.com/software/BeautifulSoup/zine/), a zine I
|
||||
wrote about what Beautiful Soup has taught me about software
|
||||
development.
|
||||
|
||||
# Building the documentation
|
||||
|
||||
The bs4/doc/ directory contains full documentation in Sphinx
|
||||
format. Run `make html` in that directory to create HTML
|
||||
documentation.
|
||||
|
||||
# Running the unit tests
|
||||
|
||||
Beautiful Soup supports unit test discovery from the project root directory:
|
||||
|
||||
```
|
||||
$ nosetests
|
||||
```
|
||||
|
||||
```
|
||||
$ python -m unittest discover -s bs4
|
||||
```
|
||||
|
||||
If you checked out the source tree, you should see a script in the
|
||||
home directory called test-all-versions. This script will run the unit
|
||||
tests under Python 2, then create a temporary Python 3 conversion of
|
||||
the source and run the unit tests again under Python 3.
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
beautifulsoup4-4.8.1.dist-info/DESCRIPTION.rst,sha256=TUEndO1FnBoCMGIeuX9tkAhKSylXB1t_NUSYxDo6ce4,3010
|
||||
beautifulsoup4-4.8.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
beautifulsoup4-4.8.1.dist-info/METADATA,sha256=ZQSTtI3Y6TP3LVrckhEel5QhfhqT8pwwvBuronGBz34,4020
|
||||
beautifulsoup4-4.8.1.dist-info/RECORD,,
|
||||
beautifulsoup4-4.8.1.dist-info/WHEEL,sha256=rNo05PbNqwnXiIHFsYm0m22u4Zm6YJtugFG2THx4w3g,92
|
||||
beautifulsoup4-4.8.1.dist-info/metadata.json,sha256=RNf83TEq3M65TUoCk_oElvbCdiLyo_AQuj0f7SNVEGc,1144
|
||||
beautifulsoup4-4.8.1.dist-info/top_level.txt,sha256=H8VT-IuPWLzQqwG9_eChjXDJ1z0H9RRebdSR90Bjnkw,4
|
||||
bs4/__init__.py,sha256=VF0X3wc9hsmeJiMt630mwChrwIc58DYt4c9vP2ky-w4,25903
|
||||
bs4/__pycache__/__init__.cpython-37.pyc,,
|
||||
bs4/__pycache__/check_block.cpython-37.pyc,,
|
||||
bs4/__pycache__/dammit.cpython-37.pyc,,
|
||||
bs4/__pycache__/diagnose.cpython-37.pyc,,
|
||||
bs4/__pycache__/element.cpython-37.pyc,,
|
||||
bs4/__pycache__/formatter.cpython-37.pyc,,
|
||||
bs4/__pycache__/testing.cpython-37.pyc,,
|
||||
bs4/builder/__init__.py,sha256=e_vTLD3AkgUTjUXkc04b0FZHJBRaVM8SDxvVNMnLXtE,14749
|
||||
bs4/builder/__pycache__/__init__.cpython-37.pyc,,
|
||||
bs4/builder/__pycache__/_html5lib.cpython-37.pyc,,
|
||||
bs4/builder/__pycache__/_htmlparser.cpython-37.pyc,,
|
||||
bs4/builder/__pycache__/_lxml.cpython-37.pyc,,
|
||||
bs4/builder/_html5lib.py,sha256=105ocel2oFeApKaPem5XtjL67kO5rKJxM5_6B2gxBw0,18088
|
||||
bs4/builder/_htmlparser.py,sha256=AKpOnUAoPBYi7x0Y1fTb1Uxrxb2EFroWIdCWgwShcF4,13653
|
||||
bs4/builder/_lxml.py,sha256=BsJBgIoyIZYY001TSHLtEsJtYD5hCXhldwpUEaYaJkg,11114
|
||||
bs4/check_block.py,sha256=ltAO73VRGrGcO0bVPMd0GdTlIg9eVTCGnnZiPbKzFI0,132
|
||||
bs4/dammit.py,sha256=VcHa3eSGP6bL3UuCrjMy_auYO7tTH42I-lhNDbrMsy8,31028
|
||||
bs4/diagnose.py,sha256=wvGDZf6VNj6rwDjU3xOsz90z2KZiBWgpu-GRqWfR6is,6966
|
||||
bs4/element.py,sha256=ebosrK3jVgnZ4Dr7kmrJdfRUu8JkENXKQHwNKPcA2QE,59447
|
||||
bs4/formatter.py,sha256=G2AYBRjeX404vLNwIPbjiG8KDjuoCqrgi9NHua6o34M,3199
|
||||
bs4/testing.py,sha256=MBsN77WRpB1Z78Y0pV7RlwbMWGfEU1iPySFKE-JJIgc,41306
|
||||
bs4/tests/__init__.py,sha256=bdUBDE750n7qNEfue7-3a1fBaUxJlvZMkvJvZa-lbYs,27
|
||||
bs4/tests/__pycache__/__init__.cpython-37.pyc,,
|
||||
bs4/tests/__pycache__/test_builder_registry.cpython-37.pyc,,
|
||||
bs4/tests/__pycache__/test_docs.cpython-37.pyc,,
|
||||
bs4/tests/__pycache__/test_html5lib.cpython-37.pyc,,
|
||||
bs4/tests/__pycache__/test_htmlparser.cpython-37.pyc,,
|
||||
bs4/tests/__pycache__/test_lxml.cpython-37.pyc,,
|
||||
bs4/tests/__pycache__/test_soup.cpython-37.pyc,,
|
||||
bs4/tests/__pycache__/test_tree.cpython-37.pyc,,
|
||||
bs4/tests/test_builder_registry.py,sha256=pllfRpArh9TYhjjRUiu1wITr9Ryyv4hiaAtRjij-k4E,5582
|
||||
bs4/tests/test_docs.py,sha256=FXfz2bGL4Xe0q6duwpmg9hmFiZuU4DVJPNZ0hTb6aH4,1067
|
||||
bs4/tests/test_html5lib.py,sha256=R2zNUUbUa3WnSqGGOiARKDWH1TLguogluqQDr10Gick,6493
|
||||
bs4/tests/test_htmlparser.py,sha256=N-wPX5jDOy7b8xUv9pHEIEfEFjOitLuD9V1blKcbscM,2354
|
||||
bs4/tests/test_lxml.py,sha256=xJr8eDrtHSb_vQw88lYEKyfdM1Hel4-dBaz14vQq78M,4105
|
||||
bs4/tests/test_soup.py,sha256=JbjlyIKCmUnVNfEHq3aPjyj-w7WZEgE9cAV-LOx6xwo,27613
|
||||
bs4/tests/test_tree.py,sha256=XBRpEOpAEvDhOeSSN857U5OcjdvfqmYT3bDNN8Qbabw,86259
|
||||
@@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.29.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Text Processing :: Markup :: HTML", "Topic :: Text Processing :: Markup :: XML", "Topic :: Text Processing :: Markup :: SGML", "Topic :: Software Development :: Libraries :: Python Modules"], "download_url": "http://www.crummy.com/software/BeautifulSoup/bs4/download/", "extensions": {"python.details": {"contacts": [{"email": "leonardr@segfault.org", "name": "Leonard Richardson", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "http://www.crummy.com/software/BeautifulSoup/bs4/"}}}, "extras": ["html5lib", "lxml"], "generator": "bdist_wheel (0.29.0)", "license": "MIT", "metadata_version": "2.0", "name": "beautifulsoup4", "run_requires": [{"extra": "html5lib", "requires": ["html5lib"]}, {"extra": "lxml", "requires": ["lxml"]}, {"requires": ["soupsieve (>=1.2)"]}], "summary": "Screen-scraping library", "version": "4.8.1"}
|
||||
@@ -0,0 +1 @@
|
||||
bs4
|
||||
655
venv/lib/python3.7/site-packages/bs4/__init__.py
Normal file
655
venv/lib/python3.7/site-packages/bs4/__init__.py
Normal file
@@ -0,0 +1,655 @@
|
||||
"""Beautiful Soup
|
||||
Elixir and Tonic
|
||||
"The Screen-Scraper's Friend"
|
||||
http://www.crummy.com/software/BeautifulSoup/
|
||||
|
||||
Beautiful Soup uses a pluggable XML or HTML parser to parse a
|
||||
(possibly invalid) document into a tree representation. Beautiful Soup
|
||||
provides methods and Pythonic idioms that make it easy to navigate,
|
||||
search, and modify the parse tree.
|
||||
|
||||
Beautiful Soup works with Python 2.7 and up. It works better if lxml
|
||||
and/or html5lib is installed.
|
||||
|
||||
For more than you ever wanted to know about Beautiful Soup, see the
|
||||
documentation:
|
||||
http://www.crummy.com/software/BeautifulSoup/bs4/doc/
|
||||
|
||||
"""
|
||||
|
||||
__author__ = "Leonard Richardson (leonardr@segfault.org)"
|
||||
__version__ = "4.8.1"
|
||||
__copyright__ = "Copyright (c) 2004-2019 Leonard Richardson"
|
||||
# Use of this source code is governed by the MIT license.
|
||||
__license__ = "MIT"
|
||||
|
||||
__all__ = ['BeautifulSoup']
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
import warnings
|
||||
|
||||
from .builder import builder_registry, ParserRejectedMarkup
|
||||
from .dammit import UnicodeDammit
|
||||
from .element import (
|
||||
CData,
|
||||
Comment,
|
||||
DEFAULT_OUTPUT_ENCODING,
|
||||
Declaration,
|
||||
Doctype,
|
||||
NavigableString,
|
||||
PageElement,
|
||||
ProcessingInstruction,
|
||||
ResultSet,
|
||||
SoupStrainer,
|
||||
Tag,
|
||||
)
|
||||
|
||||
# The very first thing we do is give a useful error if someone is
|
||||
# running this code under Python 3 without converting it.
|
||||
'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'!='You need to convert the code, either by installing it (`python setup.py install`) or by running 2to3 (`2to3 -w bs4`).'
|
||||
|
||||
class BeautifulSoup(Tag):
|
||||
"""
|
||||
This class defines the basic interface called by the tree builders.
|
||||
|
||||
These methods will be called by the parser:
|
||||
reset()
|
||||
feed(markup)
|
||||
|
||||
The tree builder may call these methods from its feed() implementation:
|
||||
handle_starttag(name, attrs) # See note about return value
|
||||
handle_endtag(name)
|
||||
handle_data(data) # Appends to the current data node
|
||||
endData(containerClass) # Ends the current data node
|
||||
|
||||
No matter how complicated the underlying parser is, you should be
|
||||
able to build a tree using 'start tag' events, 'end tag' events,
|
||||
'data' events, and "done with data" events.
|
||||
|
||||
If you encounter an empty-element tag (aka a self-closing tag,
|
||||
like HTML's <br> tag), call handle_starttag and then
|
||||
handle_endtag.
|
||||
"""
|
||||
ROOT_TAG_NAME = '[document]'
|
||||
|
||||
# If the end-user gives no indication which tree builder they
|
||||
# want, look for one with these features.
|
||||
DEFAULT_BUILDER_FEATURES = ['html', 'fast']
|
||||
|
||||
ASCII_SPACES = '\x20\x0a\x09\x0c\x0d'
|
||||
|
||||
NO_PARSER_SPECIFIED_WARNING = "No parser was explicitly specified, so I'm using the best available %(markup_type)s parser for this system (\"%(parser)s\"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.\n\nThe code that caused this warning is on line %(line_number)s of the file %(filename)s. To get rid of this warning, pass the additional argument 'features=\"%(parser)s\"' to the BeautifulSoup constructor.\n"
|
||||
|
||||
def __init__(self, markup="", features=None, builder=None,
|
||||
parse_only=None, from_encoding=None, exclude_encodings=None,
|
||||
element_classes=None, **kwargs):
|
||||
"""Constructor.
|
||||
|
||||
:param markup: A string or a file-like object representing
|
||||
markup to be parsed.
|
||||
|
||||
:param features: Desirable features of the parser to be used. This
|
||||
may be the name of a specific parser ("lxml", "lxml-xml",
|
||||
"html.parser", or "html5lib") or it may be the type of markup
|
||||
to be used ("html", "html5", "xml"). It's recommended that you
|
||||
name a specific parser, so that Beautiful Soup gives you the
|
||||
same results across platforms and virtual environments.
|
||||
|
||||
:param builder: A TreeBuilder subclass to instantiate (or
|
||||
instance to use) instead of looking one up based on
|
||||
`features`. You only need to use this if you've implemented a
|
||||
custom TreeBuilder.
|
||||
|
||||
:param parse_only: A SoupStrainer. Only parts of the document
|
||||
matching the SoupStrainer will be considered. This is useful
|
||||
when parsing part of a document that would otherwise be too
|
||||
large to fit into memory.
|
||||
|
||||
:param from_encoding: A string indicating the encoding of the
|
||||
document to be parsed. Pass this in if Beautiful Soup is
|
||||
guessing wrongly about the document's encoding.
|
||||
|
||||
:param exclude_encodings: A list of strings indicating
|
||||
encodings known to be wrong. Pass this in if you don't know
|
||||
the document's encoding but you know Beautiful Soup's guess is
|
||||
wrong.
|
||||
|
||||
:param element_classes: A dictionary mapping BeautifulSoup
|
||||
classes like Tag and NavigableString to other classes you'd
|
||||
like to be instantiated instead as the parse tree is
|
||||
built. This is useful for using subclasses to modify the
|
||||
default behavior of Tag or NavigableString.
|
||||
|
||||
:param kwargs: For backwards compatibility purposes, the
|
||||
constructor accepts certain keyword arguments used in
|
||||
Beautiful Soup 3. None of these arguments do anything in
|
||||
Beautiful Soup 4; they will result in a warning and then be ignored.
|
||||
|
||||
Apart from this, any keyword arguments passed into the BeautifulSoup
|
||||
constructor are propagated to the TreeBuilder constructor. This
|
||||
makes it possible to configure a TreeBuilder beyond saying
|
||||
which one to use.
|
||||
|
||||
"""
|
||||
|
||||
if 'convertEntities' in kwargs:
|
||||
del kwargs['convertEntities']
|
||||
warnings.warn(
|
||||
"BS4 does not respect the convertEntities argument to the "
|
||||
"BeautifulSoup constructor. Entities are always converted "
|
||||
"to Unicode characters.")
|
||||
|
||||
if 'markupMassage' in kwargs:
|
||||
del kwargs['markupMassage']
|
||||
warnings.warn(
|
||||
"BS4 does not respect the markupMassage argument to the "
|
||||
"BeautifulSoup constructor. The tree builder is responsible "
|
||||
"for any necessary markup massage.")
|
||||
|
||||
if 'smartQuotesTo' in kwargs:
|
||||
del kwargs['smartQuotesTo']
|
||||
warnings.warn(
|
||||
"BS4 does not respect the smartQuotesTo argument to the "
|
||||
"BeautifulSoup constructor. Smart quotes are always converted "
|
||||
"to Unicode characters.")
|
||||
|
||||
if 'selfClosingTags' in kwargs:
|
||||
del kwargs['selfClosingTags']
|
||||
warnings.warn(
|
||||
"BS4 does not respect the selfClosingTags argument to the "
|
||||
"BeautifulSoup constructor. The tree builder is responsible "
|
||||
"for understanding self-closing tags.")
|
||||
|
||||
if 'isHTML' in kwargs:
|
||||
del kwargs['isHTML']
|
||||
warnings.warn(
|
||||
"BS4 does not respect the isHTML argument to the "
|
||||
"BeautifulSoup constructor. Suggest you use "
|
||||
"features='lxml' for HTML and features='lxml-xml' for "
|
||||
"XML.")
|
||||
|
||||
def deprecated_argument(old_name, new_name):
|
||||
if old_name in kwargs:
|
||||
warnings.warn(
|
||||
'The "%s" argument to the BeautifulSoup constructor '
|
||||
'has been renamed to "%s."' % (old_name, new_name))
|
||||
value = kwargs[old_name]
|
||||
del kwargs[old_name]
|
||||
return value
|
||||
return None
|
||||
|
||||
parse_only = parse_only or deprecated_argument(
|
||||
"parseOnlyThese", "parse_only")
|
||||
|
||||
from_encoding = from_encoding or deprecated_argument(
|
||||
"fromEncoding", "from_encoding")
|
||||
|
||||
if from_encoding and isinstance(markup, str):
|
||||
warnings.warn("You provided Unicode markup but also provided a value for from_encoding. Your from_encoding will be ignored.")
|
||||
from_encoding = None
|
||||
|
||||
self.element_classes = element_classes or dict()
|
||||
|
||||
# We need this information to track whether or not the builder
|
||||
# was specified well enough that we can omit the 'you need to
|
||||
# specify a parser' warning.
|
||||
original_builder = builder
|
||||
original_features = features
|
||||
|
||||
if isinstance(builder, type):
|
||||
# A builder class was passed in; it needs to be instantiated.
|
||||
builder_class = builder
|
||||
builder = None
|
||||
elif builder is None:
|
||||
if isinstance(features, str):
|
||||
features = [features]
|
||||
if features is None or len(features) == 0:
|
||||
features = self.DEFAULT_BUILDER_FEATURES
|
||||
builder_class = builder_registry.lookup(*features)
|
||||
if builder_class is None:
|
||||
raise FeatureNotFound(
|
||||
"Couldn't find a tree builder with the features you "
|
||||
"requested: %s. Do you need to install a parser library?"
|
||||
% ",".join(features))
|
||||
|
||||
# At this point either we have a TreeBuilder instance in
|
||||
# builder, or we have a builder_class that we can instantiate
|
||||
# with the remaining **kwargs.
|
||||
if builder is None:
|
||||
builder = builder_class(**kwargs)
|
||||
if not original_builder and not (
|
||||
original_features == builder.NAME or
|
||||
original_features in builder.ALTERNATE_NAMES
|
||||
):
|
||||
if builder.is_xml:
|
||||
markup_type = "XML"
|
||||
else:
|
||||
markup_type = "HTML"
|
||||
|
||||
# This code adapted from warnings.py so that we get the same line
|
||||
# of code as our warnings.warn() call gets, even if the answer is wrong
|
||||
# (as it may be in a multithreading situation).
|
||||
caller = None
|
||||
try:
|
||||
caller = sys._getframe(1)
|
||||
except ValueError:
|
||||
pass
|
||||
if caller:
|
||||
globals = caller.f_globals
|
||||
line_number = caller.f_lineno
|
||||
else:
|
||||
globals = sys.__dict__
|
||||
line_number= 1
|
||||
filename = globals.get('__file__')
|
||||
if filename:
|
||||
fnl = filename.lower()
|
||||
if fnl.endswith((".pyc", ".pyo")):
|
||||
filename = filename[:-1]
|
||||
if filename:
|
||||
# If there is no filename at all, the user is most likely in a REPL,
|
||||
# and the warning is not necessary.
|
||||
values = dict(
|
||||
filename=filename,
|
||||
line_number=line_number,
|
||||
parser=builder.NAME,
|
||||
markup_type=markup_type
|
||||
)
|
||||
warnings.warn(self.NO_PARSER_SPECIFIED_WARNING % values, stacklevel=2)
|
||||
else:
|
||||
if kwargs:
|
||||
warnings.warn("Keyword arguments to the BeautifulSoup constructor will be ignored. These would normally be passed into the TreeBuilder constructor, but a TreeBuilder instance was passed in as `builder`.")
|
||||
|
||||
self.builder = builder
|
||||
self.is_xml = builder.is_xml
|
||||
self.known_xml = self.is_xml
|
||||
self._namespaces = dict()
|
||||
self.parse_only = parse_only
|
||||
|
||||
self.builder.initialize_soup(self)
|
||||
|
||||
if hasattr(markup, 'read'): # It's a file-type object.
|
||||
markup = markup.read()
|
||||
elif len(markup) <= 256 and (
|
||||
(isinstance(markup, bytes) and not b'<' in markup)
|
||||
or (isinstance(markup, str) and not '<' in markup)
|
||||
):
|
||||
# Print out warnings for a couple beginner problems
|
||||
# involving passing non-markup to Beautiful Soup.
|
||||
# Beautiful Soup will still parse the input as markup,
|
||||
# just in case that's what the user really wants.
|
||||
if (isinstance(markup, str)
|
||||
and not os.path.supports_unicode_filenames):
|
||||
possible_filename = markup.encode("utf8")
|
||||
else:
|
||||
possible_filename = markup
|
||||
is_file = False
|
||||
try:
|
||||
is_file = os.path.exists(possible_filename)
|
||||
except Exception as e:
|
||||
# This is almost certainly a problem involving
|
||||
# characters not valid in filenames on this
|
||||
# system. Just let it go.
|
||||
pass
|
||||
if is_file:
|
||||
if isinstance(markup, str):
|
||||
markup = markup.encode("utf8")
|
||||
warnings.warn(
|
||||
'"%s" looks like a filename, not markup. You should'
|
||||
' probably open this file and pass the filehandle into'
|
||||
' Beautiful Soup.' % markup)
|
||||
self._check_markup_is_url(markup)
|
||||
|
||||
rejections = []
|
||||
success = False
|
||||
for (self.markup, self.original_encoding, self.declared_html_encoding,
|
||||
self.contains_replacement_characters) in (
|
||||
self.builder.prepare_markup(
|
||||
markup, from_encoding, exclude_encodings=exclude_encodings)):
|
||||
self.reset()
|
||||
try:
|
||||
self._feed()
|
||||
success = True
|
||||
break
|
||||
except ParserRejectedMarkup as e:
|
||||
rejections.append(e)
|
||||
pass
|
||||
|
||||
if not success:
|
||||
other_exceptions = [str(e) for e in rejections]
|
||||
raise ParserRejectedMarkup(
|
||||
"The markup you provided was rejected by the parser. Trying a different parser or a different encoding may help.\n\nOriginal exception(s) from parser:\n " + "\n ".join(other_exceptions)
|
||||
)
|
||||
|
||||
# Clear out the markup and remove the builder's circular
|
||||
# reference to this object.
|
||||
self.markup = None
|
||||
self.builder.soup = None
|
||||
|
||||
def __copy__(self):
|
||||
copy = type(self)(
|
||||
self.encode('utf-8'), builder=self.builder, from_encoding='utf-8'
|
||||
)
|
||||
|
||||
# Although we encoded the tree to UTF-8, that may not have
|
||||
# been the encoding of the original markup. Set the copy's
|
||||
# .original_encoding to reflect the original object's
|
||||
# .original_encoding.
|
||||
copy.original_encoding = self.original_encoding
|
||||
return copy
|
||||
|
||||
def __getstate__(self):
|
||||
# Frequently a tree builder can't be pickled.
|
||||
d = dict(self.__dict__)
|
||||
if 'builder' in d and not self.builder.picklable:
|
||||
d['builder'] = None
|
||||
return d
|
||||
|
||||
@staticmethod
|
||||
def _check_markup_is_url(markup):
|
||||
"""
|
||||
Check if markup looks like it's actually a url and raise a warning
|
||||
if so. Markup can be unicode or str (py2) / bytes (py3).
|
||||
"""
|
||||
if isinstance(markup, bytes):
|
||||
space = b' '
|
||||
cant_start_with = (b"http:", b"https:")
|
||||
elif isinstance(markup, str):
|
||||
space = ' '
|
||||
cant_start_with = ("http:", "https:")
|
||||
else:
|
||||
return
|
||||
|
||||
if any(markup.startswith(prefix) for prefix in cant_start_with):
|
||||
if not space in markup:
|
||||
if isinstance(markup, bytes):
|
||||
decoded_markup = markup.decode('utf-8', 'replace')
|
||||
else:
|
||||
decoded_markup = markup
|
||||
warnings.warn(
|
||||
'"%s" looks like a URL. Beautiful Soup is not an'
|
||||
' HTTP client. You should probably use an HTTP client like'
|
||||
' requests to get the document behind the URL, and feed'
|
||||
' that document to Beautiful Soup.' % decoded_markup
|
||||
)
|
||||
|
||||
def _feed(self):
|
||||
# Convert the document to Unicode.
|
||||
self.builder.reset()
|
||||
|
||||
self.builder.feed(self.markup)
|
||||
# Close out any unfinished strings and close all the open tags.
|
||||
self.endData()
|
||||
while self.currentTag.name != self.ROOT_TAG_NAME:
|
||||
self.popTag()
|
||||
|
||||
def reset(self):
|
||||
Tag.__init__(self, self, self.builder, self.ROOT_TAG_NAME)
|
||||
self.hidden = 1
|
||||
self.builder.reset()
|
||||
self.current_data = []
|
||||
self.currentTag = None
|
||||
self.tagStack = []
|
||||
self.preserve_whitespace_tag_stack = []
|
||||
self.pushTag(self)
|
||||
|
||||
def new_tag(self, name, namespace=None, nsprefix=None, attrs={},
|
||||
sourceline=None, sourcepos=None, **kwattrs):
|
||||
"""Create a new tag associated with this soup."""
|
||||
kwattrs.update(attrs)
|
||||
return self.element_classes.get(Tag, Tag)(
|
||||
None, self.builder, name, namespace, nsprefix, kwattrs,
|
||||
sourceline=sourceline, sourcepos=sourcepos
|
||||
)
|
||||
|
||||
def new_string(self, s, subclass=None):
|
||||
"""Create a new NavigableString associated with this soup."""
|
||||
subclass = subclass or self.element_classes.get(
|
||||
NavigableString, NavigableString
|
||||
)
|
||||
return subclass(s)
|
||||
|
||||
def insert_before(self, successor):
|
||||
raise NotImplementedError("BeautifulSoup objects don't support insert_before().")
|
||||
|
||||
def insert_after(self, successor):
|
||||
raise NotImplementedError("BeautifulSoup objects don't support insert_after().")
|
||||
|
||||
def popTag(self):
|
||||
tag = self.tagStack.pop()
|
||||
if self.preserve_whitespace_tag_stack and tag == self.preserve_whitespace_tag_stack[-1]:
|
||||
self.preserve_whitespace_tag_stack.pop()
|
||||
#print "Pop", tag.name
|
||||
if self.tagStack:
|
||||
self.currentTag = self.tagStack[-1]
|
||||
return self.currentTag
|
||||
|
||||
def pushTag(self, tag):
|
||||
#print "Push", tag.name
|
||||
if self.currentTag is not None:
|
||||
self.currentTag.contents.append(tag)
|
||||
self.tagStack.append(tag)
|
||||
self.currentTag = self.tagStack[-1]
|
||||
if tag.name in self.builder.preserve_whitespace_tags:
|
||||
self.preserve_whitespace_tag_stack.append(tag)
|
||||
|
||||
def endData(self, containerClass=None):
|
||||
|
||||
# Default container is NavigableString.
|
||||
containerClass = containerClass or NavigableString
|
||||
|
||||
# The user may want us to instantiate some alias for the
|
||||
# container class.
|
||||
containerClass = self.element_classes.get(
|
||||
containerClass, containerClass
|
||||
)
|
||||
|
||||
if self.current_data:
|
||||
current_data = ''.join(self.current_data)
|
||||
# If whitespace is not preserved, and this string contains
|
||||
# nothing but ASCII spaces, replace it with a single space
|
||||
# or newline.
|
||||
if not self.preserve_whitespace_tag_stack:
|
||||
strippable = True
|
||||
for i in current_data:
|
||||
if i not in self.ASCII_SPACES:
|
||||
strippable = False
|
||||
break
|
||||
if strippable:
|
||||
if '\n' in current_data:
|
||||
current_data = '\n'
|
||||
else:
|
||||
current_data = ' '
|
||||
|
||||
# Reset the data collector.
|
||||
self.current_data = []
|
||||
|
||||
# Should we add this string to the tree at all?
|
||||
if self.parse_only and len(self.tagStack) <= 1 and \
|
||||
(not self.parse_only.text or \
|
||||
not self.parse_only.search(current_data)):
|
||||
return
|
||||
|
||||
o = containerClass(current_data)
|
||||
self.object_was_parsed(o)
|
||||
|
||||
def object_was_parsed(self, o, parent=None, most_recent_element=None):
|
||||
"""Add an object to the parse tree."""
|
||||
if parent is None:
|
||||
parent = self.currentTag
|
||||
if most_recent_element is not None:
|
||||
previous_element = most_recent_element
|
||||
else:
|
||||
previous_element = self._most_recent_element
|
||||
|
||||
next_element = previous_sibling = next_sibling = None
|
||||
if isinstance(o, Tag):
|
||||
next_element = o.next_element
|
||||
next_sibling = o.next_sibling
|
||||
previous_sibling = o.previous_sibling
|
||||
if previous_element is None:
|
||||
previous_element = o.previous_element
|
||||
|
||||
fix = parent.next_element is not None
|
||||
|
||||
o.setup(parent, previous_element, next_element, previous_sibling, next_sibling)
|
||||
|
||||
self._most_recent_element = o
|
||||
parent.contents.append(o)
|
||||
|
||||
# Check if we are inserting into an already parsed node.
|
||||
if fix:
|
||||
self._linkage_fixer(parent)
|
||||
|
||||
def _linkage_fixer(self, el):
|
||||
"""Make sure linkage of this fragment is sound."""
|
||||
|
||||
first = el.contents[0]
|
||||
child = el.contents[-1]
|
||||
descendant = child
|
||||
|
||||
if child is first and el.parent is not None:
|
||||
# Parent should be linked to first child
|
||||
el.next_element = child
|
||||
# We are no longer linked to whatever this element is
|
||||
prev_el = child.previous_element
|
||||
if prev_el is not None and prev_el is not el:
|
||||
prev_el.next_element = None
|
||||
# First child should be linked to the parent, and no previous siblings.
|
||||
child.previous_element = el
|
||||
child.previous_sibling = None
|
||||
|
||||
# We have no sibling as we've been appended as the last.
|
||||
child.next_sibling = None
|
||||
|
||||
# This index is a tag, dig deeper for a "last descendant"
|
||||
if isinstance(child, Tag) and child.contents:
|
||||
descendant = child._last_descendant(False)
|
||||
|
||||
# As the final step, link last descendant. It should be linked
|
||||
# to the parent's next sibling (if found), else walk up the chain
|
||||
# and find a parent with a sibling. It should have no next sibling.
|
||||
descendant.next_element = None
|
||||
descendant.next_sibling = None
|
||||
target = el
|
||||
while True:
|
||||
if target is None:
|
||||
break
|
||||
elif target.next_sibling is not None:
|
||||
descendant.next_element = target.next_sibling
|
||||
target.next_sibling.previous_element = child
|
||||
break
|
||||
target = target.parent
|
||||
|
||||
def _popToTag(self, name, nsprefix=None, inclusivePop=True):
|
||||
"""Pops the tag stack up to and including the most recent
|
||||
instance of the given tag. If inclusivePop is false, pops the tag
|
||||
stack up to but *not* including the most recent instqance of
|
||||
the given tag."""
|
||||
#print "Popping to %s" % name
|
||||
if name == self.ROOT_TAG_NAME:
|
||||
# The BeautifulSoup object itself can never be popped.
|
||||
return
|
||||
|
||||
most_recently_popped = None
|
||||
|
||||
stack_size = len(self.tagStack)
|
||||
for i in range(stack_size - 1, 0, -1):
|
||||
t = self.tagStack[i]
|
||||
if (name == t.name and nsprefix == t.prefix):
|
||||
if inclusivePop:
|
||||
most_recently_popped = self.popTag()
|
||||
break
|
||||
most_recently_popped = self.popTag()
|
||||
|
||||
return most_recently_popped
|
||||
|
||||
def handle_starttag(self, name, namespace, nsprefix, attrs, sourceline=None,
|
||||
sourcepos=None):
|
||||
"""Push a start tag on to the stack.
|
||||
|
||||
If this method returns None, the tag was rejected by the
|
||||
SoupStrainer. You should proceed as if the tag had not occurred
|
||||
in the document. For instance, if this was a self-closing tag,
|
||||
don't call handle_endtag.
|
||||
"""
|
||||
|
||||
# print "Start tag %s: %s" % (name, attrs)
|
||||
self.endData()
|
||||
|
||||
if (self.parse_only and len(self.tagStack) <= 1
|
||||
and (self.parse_only.text
|
||||
or not self.parse_only.search_tag(name, attrs))):
|
||||
return None
|
||||
|
||||
tag = self.element_classes.get(Tag, Tag)(
|
||||
self, self.builder, name, namespace, nsprefix, attrs,
|
||||
self.currentTag, self._most_recent_element,
|
||||
sourceline=sourceline, sourcepos=sourcepos
|
||||
)
|
||||
if tag is None:
|
||||
return tag
|
||||
if self._most_recent_element is not None:
|
||||
self._most_recent_element.next_element = tag
|
||||
self._most_recent_element = tag
|
||||
self.pushTag(tag)
|
||||
return tag
|
||||
|
||||
def handle_endtag(self, name, nsprefix=None):
|
||||
#print "End tag: " + name
|
||||
self.endData()
|
||||
self._popToTag(name, nsprefix)
|
||||
|
||||
def handle_data(self, data):
|
||||
self.current_data.append(data)
|
||||
|
||||
def decode(self, pretty_print=False,
|
||||
eventual_encoding=DEFAULT_OUTPUT_ENCODING,
|
||||
formatter="minimal"):
|
||||
"""Returns a string or Unicode representation of this document.
|
||||
To get Unicode, pass None for encoding."""
|
||||
|
||||
if self.is_xml:
|
||||
# Print the XML declaration
|
||||
encoding_part = ''
|
||||
if eventual_encoding != None:
|
||||
encoding_part = ' encoding="%s"' % eventual_encoding
|
||||
prefix = '<?xml version="1.0"%s?>\n' % encoding_part
|
||||
else:
|
||||
prefix = ''
|
||||
if not pretty_print:
|
||||
indent_level = None
|
||||
else:
|
||||
indent_level = 0
|
||||
return prefix + super(BeautifulSoup, self).decode(
|
||||
indent_level, eventual_encoding, formatter)
|
||||
|
||||
# Alias to make it easier to type import: 'from bs4 import _soup'
|
||||
_s = BeautifulSoup
|
||||
_soup = BeautifulSoup
|
||||
|
||||
class BeautifulStoneSoup(BeautifulSoup):
|
||||
"""Deprecated interface to an XML parser."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['features'] = 'xml'
|
||||
warnings.warn(
|
||||
'The BeautifulStoneSoup class is deprecated. Instead of using '
|
||||
'it, pass features="xml" into the BeautifulSoup constructor.')
|
||||
super(BeautifulStoneSoup, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class StopParsing(Exception):
|
||||
pass
|
||||
|
||||
class FeatureNotFound(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
#By default, act as an HTML pretty-printer.
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
soup = BeautifulSoup(sys.stdin)
|
||||
print(soup.prettify())
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user