File size: 3,237 Bytes
9b7bb21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# How this dataset was built

| File | Purpose |
|---|---|
| [`crawler.py`](./crawler.py) | Distributed whole-site crawler for `euobserver.com`. Writes one JSON file per article to `pages/`. |
| [`finalize.ipynb`](./finalize.ipynb) | Merges `pages/*.json` into a single table, deduplicates it and pushes it to the Hub. |
| [`.env.example`](./.env.example) | Configuration template. Copy to `.env` and uncomment what you need. |
| [`proxies.example.txt`](./proxies.example.txt) | Proxy-list template for `SCRAPER_PROXY_FILE` — one proxy per line. |

```bash
pip install mechanicalsoup beautifulsoup4 lxml python-dateutil fake-useragent \
            pandas datasets huggingface_hub tqdm

python crawler.py          # writes pages/*.json; `touch killall.txt` to stop
jupyter notebook finalize.ipynb
```

## Configuration

All settings are optional and are read from the environment or from a `.env`
file next to `crawler.py`. The defaults are exactly the values used for the
original crawl.

```bash
cp .env.example .env     # then uncomment what you need
```

| Variable | Meaning |
|---|---|
| `SCRAPER_PROXIES` | Inline proxy pool — entries separated by commas, semicolons, spaces or newlines. |
| `SCRAPER_PROXY_FILE` | Path to a file with **one proxy per line** — the practical form for a proxy farm. |
| `SCRAPER_THREADS` | Number of worker processes sharing the URL frontier. |
| `SCRAPER_TIMEOUT` | Socket timeout per request, in seconds. |
| `SCRAPER_RETRIES` | Attempts per URL before giving up. |
| `SCRAPER_START_URL` | Seed URL the crawl starts from. |

Environment variables take precedence over `.env`, so a single run can be
overridden on the command line:

```bash
SCRAPER_THREADS=4 python crawler.py
```

### Proxies

The original crawl ran behind a pool of forward proxies on a private network.
Those addresses have been removed from this published copy. A scheme is
optional on every entry (`http://` is assumed); one entry is picked per
request, so a pool spreads the load over several exits.

```bash
# a single proxy
export SCRAPER_PROXIES="proxy-a.example.com:3128"

# a small pool, rotated per request
export SCRAPER_PROXIES="proxy-a.example.com:3128,proxy-b.example.com:3128"

# with an explicit scheme and credentials
export SCRAPER_PROXIES="http://user:pass@proxy.example.com:3128"

# SOCKS, if PySocks is installed
export SCRAPER_PROXIES="socks5://localhost:9050"
```

For a **whole proxy farm**, keep the list in its own file — one proxy per line,
blank lines and `#` comments allowed — and point `SCRAPER_PROXY_FILE` at it.
The file can hold thousands of entries and be regenerated by another tool
without touching `.env` or the script:

```bash
cp proxies.example.txt proxies.txt   # then fill in your own entries
echo 'SCRAPER_PROXY_FILE=proxies.txt' >> .env
python crawler.py
```

Leave both unset to crawl over a direct connection — that is the default and
what most of the crawls in this collection used.

The scripts contain no credentials, cookies or personal data.

Please crawl responsibly: honour `robots.txt` and the site's terms of use, keep
concurrency well below the 32 workers used here unless you have the operator's
permission, and prefer the published dataset over re-crawling.