You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
__copyright__="Copyright (c) 2004-2020 Leonard Richardson"
20
20
# Use of this source code is governed by the MIT license.
21
21
__license__="MIT"
22
22
23
23
__all__= ['BeautifulSoup']
24
24
25
+
fromcollectionsimportCounter
25
26
importos
26
27
importre
27
28
importsys
@@ -39,15 +40,32 @@
39
40
NavigableString,
40
41
PageElement,
41
42
ProcessingInstruction,
43
+
PYTHON_SPECIFIC_ENCODINGS,
42
44
ResultSet,
45
+
Script,
46
+
Stylesheet,
43
47
SoupStrainer,
44
48
Tag,
49
+
TemplateString,
45
50
)
46
51
47
52
# The very first thing we do is give a useful error if someone is
48
53
# running this code under Python 3 without converting it.
49
54
'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`).'
50
55
56
+
# Define some custom warnings.
57
+
classGuessedAtParserWarning(UserWarning):
58
+
"""The warning issued when BeautifulSoup has to guess what parser to
59
+
use -- probably because no parser was specified in the constructor.
60
+
"""
61
+
62
+
classMarkupResemblesLocatorWarning(UserWarning):
63
+
"""The warning issued when BeautifulSoup is given 'markup' that
64
+
actually looks like a resource locator -- a URL or a path to a file
65
+
on disk.
66
+
"""
67
+
68
+
51
69
classBeautifulSoup(Tag):
52
70
"""A data structure representing a parsed HTML or XML document.
53
71
@@ -93,7 +111,7 @@ class BeautifulSoup(Tag):
93
111
ASCII_SPACES='\x20\x0a\x09\x0c\x0d'
94
112
95
113
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"
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`.")
0 commit comments