Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'SoupStrainer' object has no attribute 'name' #48

Open
LorhanSohaky opened this issue Feb 18, 2025 · 5 comments
Open

AttributeError: 'SoupStrainer' object has no attribute 'name' #48

LorhanSohaky opened this issue Feb 18, 2025 · 5 comments

Comments

@LorhanSohaky
Copy link

I was trying to capture the metadata but was getting this error

I tried to solve the problem (#47), but another test started failing and I didn't know how to solve it.

@rafpyprog
Copy link
Owner

@LorhanSohaky could you provide more details about your environment and also the code and error ?

@LorhanSohaky
Copy link
Author

LorhanSohaky commented Feb 20, 2025

@rafpyprog , here is the code snippet, but when I tried to troubleshoot I caught other errors (#47)

Python 3.8.16

pip freeze

beautifulsoup4==4.13.3
certifi==2025.1.31
charset-normalizer==3.4.1
html5lib==1.1
idna==3.10
numpy==1.24.4
pandas==2.0.3
python-dateutil==2.9.0.post0
pytz==2025.1
requests==2.32.3
retrying==1.3.4
sgs==2.1.1
six==1.17.0
soupsieve==2.6
typing_extensions==4.12.2
tzdata==2025.1
urllib3==2.2.3
webencodings==0.5.1

example

import sgs

series_id = 1178

metadata = sgs.metadata(series_id)

output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/teste/venv/lib/python3.8/site-packages/sgs/metadata.py", line 38, in metadata
    col_info = search_ts(ts_code, language)
  File "/teste/venv/lib/python3.8/site-packages/retrying.py", line 56, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "/teste/venv/lib/python3.8/site-packages/retrying.py", line 266, in call
    raise attempt.get()
  File "/teste/venv/lib/python3.8/site-packages/retrying.py", line 301, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "/teste/venv/lib/python3.8/site-packages/six.py", line 724, in reraise
    raise value
  File "/teste/venv/lib/python3.8/site-packages/retrying.py", line 251, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "/teste/venv/lib/python3.8/site-packages/sgs/search.py", line 176, in search_ts
    results = parse_search_response(response, language)
  File "/teste/venv/lib/python3.8/site-packages/sgs/search.py", line 80, in parse_search_response
    df = pd.read_html(HTML, attrs={"id": "tabelaSeries"}, flavor="html5lib", skiprows=1)[0]
  File "/teste/venv/lib/python3.8/site-packages/pandas/io/html.py", line 1212, in read_html
    return _parse(
  File "/teste/venv/lib/python3.8/site-packages/pandas/io/html.py", line 981, in _parse
    tables = p.parse_tables()
  File "/teste/venv/lib/python3.8/site-packages/pandas/io/html.py", line 257, in parse_tables
    tables = self._parse_tables(self._build_doc(), self.match, self.attrs)
  File "/teste/venv/lib/python3.8/site-packages/pandas/io/html.py", line 609, in _parse_tables
    element_name = self._strainer.name
AttributeError: 'SoupStrainer' object has no attribute 'name'

@rafpyprog
Copy link
Owner

rafpyprog commented Feb 21, 2025

@LorhanSohaky there was a conflict of package versions on Python 3.8. I think I managed to fix it! Could you it give a try on the branch teste-bs4 before I publish the new version ?

@LorhanSohaky
Copy link
Author

LorhanSohaky commented Feb 21, 2025

@rafpyprog , I ran the example locally and the metadata came with none. I also ran the automated test and it showed an error. Note: maybe my tests failed because of numpy

python setup.py install

Image

Image

Image

Image

@LorhanSohaky
Copy link
Author

@rafpyprog , fiz um outro teste e deu certo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants