Coder Social home page Coder Social logo

index out of range about dmarchiver HOT 6 CLOSED

vinnytroia avatar vinnytroia commented on June 12, 2024
index out of range

from dmarchiver.

Comments (6)

Mincka avatar Mincka commented on June 12, 2024 1

Thank you so much @cajuncooks for taking the time to investigate and find a workaround.
I've implemented your fix as described and published the version 0.2.6 for all platforms! πŸŽ‰

from dmarchiver.

simsala avatar simsala commented on June 12, 2024

Seeing this since last week:

DMArchiver 0.2.5
Running on Python 3.7.4 (default, Jul 9 2019, 18:14:44)
[Clang 9.0.0 (clang-900.0.39.2)]

Traceback (most recent call last):
File "dmarchiver/cmdline.py", line 134, in
File "dmarchiver/cmdline.py", line 97, in main
File "dmarchiver/core.py", line 312, in authenticate
IndexError: list index out of range
[1863] Failed to execute script cmdline

Using macOS 10.15.3

from dmarchiver.

vinnytroia avatar vinnytroia commented on June 12, 2024

Same. It’s not just Mac though. I get the same on Linux. Twitter may have changed something.

from dmarchiver.

ThomasWattez avatar ThomasWattez commented on June 12, 2024

Same on Windows 10, I hope we'll get a fix of this :(

from dmarchiver.

cajuncooks avatar cajuncooks commented on June 12, 2024

This fixed it for me. Twitter now shows a splash that asks if you want to be taken to legacy Twitter if your scraper doesn't have JS enabled. We could either run a headless Selenium webdriver (huge headache), or do this. It's not the cleanest solution, but it works, and the session saving still works, so... shrug emoji. I can open a pull, but I imagine @Mincka may want to refactor this a bit instead.

In core.py, under class Crawler(object):

add _login_headers beneath _http_headers:

    _http_headers =  {
        'User-Agent': _user_agent}
    _login_headers = {
        'User-Agent': _user_agent,
        'Referer': 'https://mobile.twitter.com/login'}

add force_nojs at the start of def authenticate:

    def authenticate(self, username, password, save_session, raw_output):
        force_nojs = 'https://mobile.twitter.com/i/nojs_router?path=%2Flogin'
        login_url = self._twitter_base_url + '/login'

and this this is the meat of the changes, just a bit further down:

        response = self._session.post(
            force_nojs,
            headers=self._login_headers)

        [...]

        document = lxml.html.document_fromstring(response.content)

Sending that post request (instead of a get, as before) to the nojs redirect is enough to get what lxml needs to parse. For whatever reason, lxml.html needs response.content instead of response.text, now, too.

I only noticed this issue because I had to change my password overnight so all of my sessions were invalidated. Good reminder to use the session saving feature! (Which I tested to still work, and requires that _http_headers stays static, i.e. no referer in the header.)

from dmarchiver.

TKaemp avatar TKaemp commented on June 12, 2024

Unfortunately, this issue does not seem to be fixed on my side. No logs are created, just the same error, but on 0.2.6 instead

DMArchiver 0.2.6
Running on Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)]

Traceback (most recent call last):
  File "dmarchiver\cmdline.py", line 134, in <module>
  File "dmarchiver\cmdline.py", line 97, in main
  File "dmarchiver\core.py", line 316, in authenticate
IndexError: list index out of range
Failed to execute script cmdline

Weirdly enough, it is running Python 3.4.4, while I only have 3.9.4 installed.

from dmarchiver.

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.