Giter Site home page Giter Site logo

Comments (3)

wumpus avatar wumpus commented on June 20, 2024 1

@KyloPrem so just to be clear, you closed this because the actual issue is receiving a 403 rate limit result, and not checking the http status. We did make a change that causes this recently, and honestly, I didn't even think of that when I read your bug report! Glad you figured it out.

from warcio.

wumpus avatar wumpus commented on June 20, 2024

From the first line printed in the exception, you can see that the file you're asking ArchiveIterator to work on is xml.

ArchiveIterator iterates over warc files. Not xml.

from warcio.

KyloPrem avatar KyloPrem commented on June 20, 2024

That is interesting. The data .tsv definitely references the common crawl archives.
https://commoncrawl.org/2016/07/
crawl-data/CC-MAIN-2016-07/segments/1454702018134.95/warc/CC-MAIN-20160205195338-00121-ip-10-236-182-209.ec2.internal.warc.gz

I tried to build a minimal example below, which gave me the above exception

import io
import time
import justext
import argparse
import requests
import pandas as pd
from tqdm import tqdm
from warcio.archiveiterator import ArchiveIterator


def download_debug():

    common_crawl_data = {"filename":"crawl-data/CC-MAIN-2016-07/segments/1454702018134.95/warc/CC-MAIN-20160205195338-00121-ip-10-236-182-209.ec2.internal.warc.gz",
                         "offset":244189209,
                         "length":989
                         }

    offset, length = int(common_crawl_data['offset']), int(common_crawl_data['length'])
    offset_end = offset + length - 1

    prefix = 'https://commoncrawl.s3.amazonaws.com/'

    resp = requests.get(prefix + common_crawl_data['filename'], headers={'Range': 'bytes={}-{}'.format(offset, offset_end)})
    raw_data = io.BytesIO(resp.content)

    uri = None
    page = None
    
    for record in ArchiveIterator(raw_data, arc2warc=True):
        uri = record.rec_headers.get_header('WARC-Target-URI')
        R = record.content_stream().read()
        try:
            page = R.strip().decode('utf-8')
        except:
            page = R.strip().decode('latin1')
        print(uri, page)
    return uri, page

download_debug()

any recommendation on how to debug this or an idea why this function would return a xml instead of the warc file?

EDIT: the request returns a 403 denied message.

from warcio.

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.