Coder Social home page Coder Social logo

Comments (8)

felipehertzer avatar felipehertzer commented on June 13, 2024 1

Hey @fortyfourforty, I can't replicate this issue with the given URL, also they aren't using json-ld. Can you provide more details as Trafilatura version?

from trafilatura.

fortyfourforty avatar fortyfourforty commented on June 13, 2024 1

Hi @felipehertzer, I just tested with a clean install the issue is gone. Guess it has to do with my own code. Thanks for your time testing!

from trafilatura.

adbar avatar adbar commented on June 13, 2024

Thanks @fortyfourforty & @felipehertzer for your feedback.

from trafilatura.

fortyfourforty avatar fortyfourforty commented on June 13, 2024

Another example of the same problem.

I've tested with a clean pip install, uses trafilatura's built-in fetch and can reproduce the same error. @felipehertzer @adbar

Error url : https://www.safetyinsurance.com/

Error: /usr/local/lib/python3.10/dist-packages/trafilatura/json_metadata.py in extract_json(schema, metadata)
63 if metadata.sitename is None or (len(metadata.sitename) < len(candidate) and content_type != "webpage"):
64 metadata.sitename = candidate
---> 65 if metadata.sitename is not None and metadata.sitename.startswith('http') and not candidate.startswith('http'):
66 metadata.sitename = candidate
67

AttributeError: 'list' object has no attribute 'startswith'

Function:
downloaded = fetch_url(url)
res = trafilatura.extract(downloaded, output_format="xml", include_comments=False)

output_format="json" also produces the same error.

The workaround is by commenting out the corresponding metadata.sitename check. But I'm also looking for an official fix.

from trafilatura.

adbar avatar adbar commented on June 13, 2024

The webpage is currently offline, I tried with an archived version (https://web.archive.org/web/20230607164633/https://www.safetyinsurance.com/) and I cannot reproduce the problem. Are you using the last Trafilatura version?

from trafilatura.

fortyfourforty avatar fortyfourforty commented on June 13, 2024

Yes, last Trafilatura version. @adbar
Pip install in colab with a new notebook dedicated for testing.

I tested again with a notebook, you can have a look.
The site is not offline as I just tested and you can also see the source in the notebook.

https://colab.research.google.com/drive/1Bm5rJpt40_veEAGREOwIw-EcMelXHiCr?usp=sharing

from trafilatura.

adbar avatar adbar commented on June 13, 2024

Thanks @fortyfourforty, I can reproduce the bug using the HTML in the notebook.

@felipehertzer Do you have an idea?

from trafilatura.

felipehertzer avatar felipehertzer commented on June 13, 2024

Hey @adbar,

The problem is that this website is using alternateName as list instead of text. I added a extra to avoid that bug.

https://schema.org/Organization

from trafilatura.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.