adbar / trafilatura

Python & Command-line tool to gather text and metadata on the Web: Crawling, scraping, extraction, output as CSV, JSON, HTML, MD, TXT, XML
https://trafilatura.readthedocs.io
Apache License 2.0
3.5k stars 254 forks source link

IndexError: pop from empty list #39

Closed t-duan closed 3 years ago

t-duan commented 3 years ago

Hi,

I tried to crawl texts from a list of 100 URLs experimentally. Every time it's stopped at the 40th with the error as follows:

$ trafilatura --inputfile linkliste-gefiltert.txt --outputdir ausgabe/ --backup-dir html-quellen/
Traceback (most recent call last):
  File "/home/anaconda3/bin/trafilatura", line 8, in <module>
    sys.exit(main())
  File "/home/anaconda3/lib/python3.7/site-packages/trafilatura/cli.py", line 151, in main
    process_args(args)
  File "/home/anaconda3/lib/python3.7/site-packages/trafilatura/cli.py", line 166, in process_args
    url_processing_pipeline(args, input_urls, SLEEP_TIME)
  File "/home/anaconda3/lib/python3.7/site-packages/trafilatura/cli_utils.py", line 306, in url_processing_pipeline
    multi_threaded_processing(domain_dict, args, sleeptime, counter)
  File "/home/anaconda3/lib/python3.7/site-packages/trafilatura/cli_utils.py", line 254, in multi_threaded_processing
    bufferlist.append(domain_dict[domain].pop())
IndexError: pop from empty list

Anyone also run into this problem?

My list is like this (a subset of corona-corpus at DWDS): http://schmid.welt.de/2020/03/18/corona-gesammelte-apercus-3 http://schmid.welt.de/2020/04/04/krieg-und-virus-corona-apercus-5 http://www.bmz.de/de/themen/corona/index.html http://www.chiemgauseiten.de/2020/04/15/zirkus-corona-tag-33-wann-wird-s-mal-wieder-richtig-schule http://www.chiemgauseiten.de/2020/04/19/zirkus-corona-tag-38-der-hasenpalast http://www.chiemgauseiten.de/2020/04/23/zirkus-corona-tag-42-die-hoffnungs-profis http://www.chiemgauseiten.de/2020/04/27/zirkus-corona-tag-45-leo-allein-zu-haus http://www.chiemgauseiten.de/2020/05/01/zirkus-corona-tag-50-das-gro%C3%9Fe-wiedersehen http://www.chiemgauseiten.de/2020/05/04/zirkus-corona-tag-53-das-corona-paradox http://www.chiemgauseiten.de/2020/05/08/zirkus-corona-tag-57-tage-der-befreiung http://www.chiemgauseiten.de/2020/05/11/zirkus-corona-tag-60-zwischenzeit http://www.klimareporter.de http://www.klimareporter.de/deutschland/der-corona-rollback http://www.klimareporter.de/finanzen-wirtschaft/finanzhilfen-nur-mit-1-5-grad-standards http://www.klimareporter.de/gesellschaft/der-klimawandel-ein-planetarisches-virus http://www.klimareporter.de/protest/das-klima-in-der-hand-der-aktionaer-innen http://www.klimareporter.de/protest/die-vermeintlich-unpolitischen-krisen http://www.klimareporter.de/verkehr/corona-zwingt-luftfahrt-zu-mehr-klimaschutz http://www.liebesleben.de/corona/corona-hiv-und-andere-sti http://www.liebesleben.de/corona/corona-sexualitaet-und-wohlbefinden http://www.liebesleben.de/corona/corona-und-beziehungen http://www.liebesleben.de/corona/corona-und-dating http://www.liebesleben.de/corona/corona-und-fragen-zu-sexualitaet http://www.liebesleben.de/corona/corona-und-sex http://www.literaturhaus-graz.at/die-corona-tagebuecher-1 http://www.literaturhaus-graz.at/die-corona-tagebuecher-teil-2 http://www.literaturhaus-graz.at/die-corona-tagebuecher-teil-3 http://www.literaturhaus-graz.at/die-corona-tagebuecher-teil-5 http://www.literaturhaus-graz.at/die-corona-tagebuecher-teil-6 http://www.literaturhaus-graz.at/ie-corona-tagebuecher-teil-8 http://www.marlenestreeruwitz.at/werk/so-ist-die-welt-geworden http://www.ortheil-blog.de/2020/04/15/exit-und-zwar-sofort http://www.ortheil-blog.de/2020/04/20/stationen-eines-corona-tages-1 http://www.ortheil-blog.de/2020/04/21/stationen-eines-coronatages-fuer-kinder http://www.ortheil-blog.de/2020/05/02/nachrichtenueberdruss http://www.tichyseinblick.de/daili-es-sentials/aemter-ignorierten-empfehlungen-der-who-und-einer-hygiene-kommission http://www.tichyseinblick.de/daili-es-sentials/agitation-oder-trost-muezzine-rufen-zum-gebet http://www.tichyseinblick.de/daili-es-sentials/altmaier-sollte-etwas-tun-oder-den-mund-halten http://www.tichyseinblick.de/daili-es-sentials/ausstieg-aus-der-quarantaene-nach-ostern-neue-daten-stuetzen-die-forderung http://www.tichyseinblick.de/daili-es-sentials/berlin-kirche-nein-revolutionaere-1-mai-demo-ja http://www.tichyseinblick.de/daili-es-sentials/bund-arbeitet-an-impfpflicht-durch-die-hintertuer http://www.tichyseinblick.de/daili-es-sentials/cdu-verschiebt-parteitag-auf-unbestimmte-zeit http://www.tichyseinblick.de/daili-es-sentials/china-coronavirus-abschottung http://www.tichyseinblick.de/daili-es-sentials/corona-abstimmung-buerger-protestieren-trotz-demonstrationsverbot http://www.tichyseinblick.de/daili-es-sentials/corona-bringts-an-den-tag-deutschland-ohne-mass-und-ordnung http://www.tichyseinblick.de/daili-es-sentials/corona-ein-kurzer-laendervergleich http://www.tichyseinblick.de/daili-es-sentials/corona-hilfe-fuer-nachbarn-solidaritaet-ist-eine-einbahnstrasse http://www.tichyseinblick.de/daili-es-sentials/corona-in-suedostasien-wie-thailand-auf-die-pandemie-reagiert http://www.tichyseinblick.de/daili-es-sentials/corona-kommunikation-schlechte-noten-fuer-bundesministerien http://www.tichyseinblick.de/daili-es-sentials/corona-schattengesetze http://www.tichyseinblick.de/daili-es-sentials/corona-und-co2-jetzt-kommen-die-engfuehrer http://www.tichyseinblick.de/daili-es-sentials/corona-update-3-mai http://www.tichyseinblick.de/daili-es-sentials/corona-update-um-18-april-die-maskenpflicht-kommt http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-1-mai-kein-tanz-dafuer-presseerklaerungen http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-10-april-eine-studie-aus-dem-kreis-heinsberg http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-12-april-die-gier-der-vermoegenden http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-14-april-anwaeltin-bahner-in-psychiatrie http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-15-april-die-leopoldina-und-die-wirtschaft http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-16-april-die-bundesregierung-fordert-zum-maskentragen-auf http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-2-mai-gerichte-werden-aktiv http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-20-april-die-lockerungen-im-ueberblick http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-22-april-spahn-fordert-toleranz-fuer-fehler-der-politik http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-24-april-eine-merkelsche-regierungserklaerung http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-25-april http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-26-april-china-uebt-druck-auf-die-eu-aus http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-27-april-spd-will-recht-auf-homeoffice-und-strichweibchen http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-27-oktober-das-parlament-stiehlt-sich-aus-der-verantwortung http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-29-april-die-bundesregierung-bekaempft-ihre-eigenen-fake-news http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-30-maerz-soziale-folgen-draengen-nach-vorne http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-4-april-wie-raus-aus-dem-kontaktverbot http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-8-april-mundschutzmasken-aber-woher http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-morgen-des-1-april-flacht-die-kurve-ab http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-morgen-des-19-maerz http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-morgen-des-20-maerz-anstieg-der-infektionen http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-morgen-des-23-maerz-deutsche-amtsstuben-und-italienische-aerzte http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-morgen-des-26-maerz-wer-wird-behandelt-wer-nicht http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-morgen-des-27-maerz http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-morgen-des-28-maerz-das-rki-taucht-ab http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-morgen-des-29-maerz-ein-vertrauliches-strategiepapier http://www.tichyseinblick.de/daili-es-sentials/corona-update-zum-morgen-des-4-april-beschlagnahmte-schutzmasken-und-hoffnung-fuer-italien http://www.tichyseinblick.de/daili-es-sentials/corona-vermoegensteuer-zwei-reichen-solis-und-eine-mauer-fuer-reiche http://www.tichyseinblick.de/daili-es-sentials/corona-verschleiert-spanien-das-ausmass-der-pandemie http://www.tichyseinblick.de/daili-es-sentials/corona-virus-ueberlebensplan-bis-zum-impfstoff http://www.tichyseinblick.de/daili-es-sentials/coronavirus-in-deutschland http://www.tichyseinblick.de/daili-es-sentials/coronavirus-in-europa-angekommen http://www.tichyseinblick.de/daili-es-sentials/coronavirus-oesterreich-ist-im-krisenmanagement-deutschland-weit-voraus http://www.tichyseinblick.de/daili-es-sentials/coronavirus-was-wir-von-der-spanischen-grippe-lernen-koennen http://www.tichyseinblick.de/daili-es-sentials/covid-19-warum-die-aktuelle-sterberate-wenig-aussagt http://www.tichyseinblick.de/daili-es-sentials/der-corona-wortschatz http://www.tichyseinblick.de/daili-es-sentials/deutschland-war-auf-corona-vorbereitet-aber-nur-auf-dem-papier http://www.tichyseinblick.de/daili-es-sentials/die-hoffnung-stirbt-zuerst-merkel-zieht-neuen-corona-gipfel-vor http://www.tichyseinblick.de/daili-es-sentials/dritter-fdp-bundestagsabgeordneter-positiv-auf-covid-19-getestet http://www.tichyseinblick.de/daili-es-sentials/ein-nachtrag-zu-systemtest-coronavirus-berlin-redet-wien-und-andere-handeln-un-und-eu-finden-nicht-statt http://www.tichyseinblick.de/daili-es-sentials/endlich-die-fdp-wacht-aus-ihrem-tiefschlaf-auf http://www.tichyseinblick.de/daili-es-sentials/engtanz-in-zeiten-von-corona http://www.tichyseinblick.de/daili-es-sentials/erste-ergebnisse-der-heinsberg-studie-koennen-die-einschraenkungen-gelockert-werden http://www.tichyseinblick.de/daili-es-sentials/fdp-abgeordneter-marcel-luthe-wir-oeffnen-die-buechse-der-pandora http://www.tichyseinblick.de/daili-es-sentials/fluege-aus-dem-iran-kommen-weiter-in-deutschland-an http://www.tichyseinblick.de/daili-es-sentials/hamburg-party-senator-bricht-corona-regeln-der-eigenen-behoerde http://www.tichyseinblick.de/daili-es-sentials/hamsterkaeufe-sorge-vor-coronavirus-und-leere-supermarktregale

adbar commented 3 years ago

Thank for the bug report, there was indeed on a problem in URL list processing, just fixed in f86e4606b32dc9e9de56f181e428b4dc1b06a4f4.

The downloads should now work if you use the newest version from the repository: pip install -U git+https://github.com/adbar/trafilatura.git

t-duan commented 3 years ago

It works now! Thank you! Another thought: will it be possible to crawl the missing websites from Internet Archive? I'm considering whether it's a good idea to archive all pages on Internet Archive automatically at the stage when crawling them for the first time. This will make it possible to rebuild exactly the same corpus. Just a thought, don't take it so seriously ;)

adbar commented 3 years ago

Good idea, I'll think about fetching dead links directly from archive.org.

Considering the interaction with web archives several Python libraries are of interest:

adbar commented 3 years ago

Referenced in #40, closing this issue for now.