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 in baseline extraction of JSON text #640

Closed
Honesty-of-the-Cavernous-Tissue opened this issue Jul 8, 2024 · 0 comments · Fixed by #643
Closed

AttributeError in baseline extraction of JSON text #640

Honesty-of-the-Cavernous-Tissue opened this issue Jul 8, 2024 · 0 comments · Fixed by #643
Labels
bug Something isn't working

Comments

@Honesty-of-the-Cavernous-Tissue

python: 3.12.0
trafilatura: 1.11.0

import trafilatura

url = 'https://sport.tvp.pl/65443054/nba-donovan-mitchell-zdobyl-71-punktow-w-meczu-z-chicago-bulls-jest-siodmym-koszykarzem-w-historii-ligi-ktory-przekroczyl-bariere-70-oczek'
resp = trafilatura.fetch_url(url)
print(trafilatura.extract(resp))
Traceback (most recent call last):
  File "/Users/zyq/CC_Cat/test.py", line 5, in <module>
    print(trafilatura.extract(resp))
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zyq/miniconda3/envs/3.12.0/lib/python3.12/site-packages/trafilatura/core.py", line 338, in extract
    document = bare_extraction(
               ^^^^^^^^^^^^^^^^
  File "/Users/zyq/miniconda3/envs/3.12.0/lib/python3.12/site-packages/trafilatura/core.py", line 206, in bare_extraction
    postbody, temp_text, len_text = baseline(deepcopy(tree_backup))
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zyq/miniconda3/envs/3.12.0/lib/python3.12/site-packages/trafilatura/baseline.py", line 49, in baseline
    text = trim(load_html(json_body).text_content()) if "<p>" in json_body else trim(json_body)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'text_content'
@adbar adbar changed the title load_html return None leads error AttributeError in baseline extraction of JSON text Jul 16, 2024
@adbar adbar added the bug Something isn't working label Jul 16, 2024
@adbar adbar linked a pull request Jul 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants