GithubHelp home page GithubHelp logo

Comments (4)

igorbrigadir avatar igorbrigadir commented on July 20, 2024

On another look, this may require some further digging. Technically, we already should be handling this - "twarc1" and "twarc2" should both handle retries for timeouts, and not retry for 404s. But it seems like 404s aren't being caught properly in twarc1 right now. So maybe there is a bug there:

twarc users acthatnotexist1

Should output a handled error, but instead

Traceback (most recent call last):
  File "/python/bin/twarc", line 11, in <module>
    load_entry_point('twarc', 'console_scripts', 'twarc')()
  File "/python/twarc/twarc/command.py", line 293, in main
    for thing in things:
  File "/python/twarc/twarc/client.py", line 372, in user_lookup
    for u in do_lookup():
  File "/python/twarc/twarc/client.py", line 361, in do_lookup
    raise e
  File "/python/twarc/twarc/client.py", line 357, in do_lookup
    resp = self.get(url, params=params, allow_404=True)
  File "/python/twarc/twarc/decorators.py", line 88, in new_f
    resp.raise_for_status()
  File "/python/lib/python3.7/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.twitter.com/1.1/users/lookup.json?screen_name=acthatnotexist1&tweet_mode=extended

A stack trace. I haven't fully replicated timeouts yet.

As an alternative - does twarc2 work better here? When users are not found, it returns an error message you can parse instead of 404 errors:

twarc2 user name accountthatdoesnotexist111
[
  {
    "errors": [
      {
        "value": "acthatnotexist1",
        "detail": "Could not find user with usernames: [acthatnotexist1].",
        "title": "Not Found Error",
        "resource_type": "user",
        "parameter": "usernames",
        "resource_id": "acthatnotexist1",
        "type": "https://api.twitter.com/2/problems/resource-not-found"
      }
    ],
    "__twarc": {...
    }
  }
]

from twarc.

antibot4navalny avatar antibot4navalny commented on July 20, 2024

If twarc2 implies having API2 access, that's a separate issue I haven't find a way to clarify: I don't have API2 access, and I'm afraid applying for it means risking my existing API1.1 access. Until then, I need to stick with 1.1.

I am ready to provide stacktrace and any further diagnostics for request timeout cases if that can help us to have some progress.

from twarc.

igorbrigadir avatar igorbrigadir commented on July 20, 2024

Oh, i see what you mean - i don't know about losing v1.1 Access, but as far as i know, brand new API accounts all get v2 access. Keeping this open for the v1.1 Errors bug tho - i'll double check stuff there for now.

from twarc.

antibot4navalny avatar antibot4navalny commented on July 20, 2024

Similar problem with twarc {friends|followers} when account is protected: exit code for requests.exceptions.HTTPError: 401 is the same 1 as for requests.exceptions.ReadTimeout.

from twarc.

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.