|
楼主 |
发表于 2024-4-15 19:35:36
|
显示全部楼层
仍然报错:
Traceback (most recent call last):
File "D:\Python\pythonProject\Ylqx20240415\行政区划2024041501_530402.py", line 106, in <module>
spider_next(get_prefix(province_url) + href, 2, sheet)
File "D:\Python\pythonProject\Ylqx20240415\行政区划2024041501_530402.py", line 61, in spider_next
spider_next(get_prefix(url) + href, lev + 1, sheet)
File "D:\Python\pythonProject\Ylqx20240415\行政区划2024041501_530402.py", line 61, in spider_next
spider_next(get_prefix(url) + href, lev + 1, sheet)
File "D:\Python\pythonProject\Ylqx20240415\行政区划2024041501_530402.py", line 53, in spider_next
for item in get_html(url).select("tr ." + spider_class):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\.venv\Lib\site-packages\bs4\element.py", line 2116, in select
return self.css.select(selector, namespaces, limit, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\.venv\Lib\site-packages\bs4\css.py", line 162, in select
self.api.select(
File "D:\Python\pythonProject\.venv\Lib\site-packages\soupsieve\__init__.py", line 147, in select
return compile(select, namespaces, flags, **kwargs).select(tag, limit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\.venv\Lib\site-packages\soupsieve\__init__.py", line 65, in compile
return cp._cached_css_compile(
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\.venv\Lib\site-packages\soupsieve\css_parser.py", line 208, in _cached_css_compile
).process_selectors(),
^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\.venv\Lib\site-packages\soupsieve\css_parser.py", line 1129, in process_selectors
return self.parse_selectors(self.selector_iter(self.pattern), index, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\.venv\Lib\site-packages\soupsieve\css_parser.py", line 965, in parse_selectors
key, m = next(iselector)
^^^^^^^^^^^^^^^
File "D:\Python\pythonProject\.venv\Lib\site-packages\soupsieve\css_parser.py", line 1122, in selector_iter
raise SelectorSyntaxError(msg, self.pattern, index)
soupsieve.util.SelectorSyntaxError: Malformed class selector at position 3
line 1:
tr .
^
|
|