Crawling Through Barclay's Implicit Research Graph

A story about trying to break into Barclay's internal research portal and doing things you aren't supposed to do.

13 Aug 2025 · 4 min read

Somewhere in junior year, I got bored of the good habit of reading books and instead started enjoying reading industry reports published by wall street banks.

Of course, this left me with a big problem: how do you find these damn things without shelling out $2k for a Bloomberg terminal? Well, following some clever social engineering (a story for another time), I finally got my hands on some research reports which were unfortunately delayed to publication and also limited in amount.

I wanted a better way to explore a large collection, but I had no obvious index I could work from. What I did notice, however, was that the reports themselves contained links to previously published research. Each hyperlink came appended with a docID and a link to a Barclays client portal.

Crawling Through Barclay's Implicit Research Graph — image 1
My prized possessions.

For me that simplified the problem, since the collection was just a graph: each report a node and its references were edges. If I could resolve those programmatically, a single known report could become the gateway into a much larger corpus.

The first step was understanding the document delivery path.

But to get there, I had to play around with requesting access to the Barclays client portal through a few different ways (fortunately for me, 1 method ended up working as was reproducible across instances).

Now that I was in, I captured a stream of browser requests browsing through different reports and then reproduced an authenticated browser request in Python (finding that documents could be requested using the internal docviewID). This gave me a minimal downloader, but only for IDs already available.

The more useful discovery came reading the PDFs themselves. Barclays publication links embedded in a report contained contentPubID identifiers.

Using a PyMuPDF processor I would then inspect both PDF hyperlink annotations and page text, extracted matching publication URLs, normalized identifiers and deduped results.

By this point the problem became graph traversal. The orchestrator started from a seed report, downloaded it, extracted its references, added unseen documents to a queue and recursively repeated the process. Using the breadth-first traversal with an explicit depth limit allowed for control over how aggressively the corpus expanded (since I found returns to be diminishing post layer 8).

This first implementation while very good at building the corpus, exposed a less obvious problem: there was a state mismatch in the logic. Failed long runs, failed authentication and expansion of depth all led to a start from zero and duplicated work. This is why I ended up adding a persisted processed document ID system.

This became more complicated once I wanted to extend existing crawls. Knowing the processing state wasn't enough since I also needed the links that had been discovered. So I changed the persistence model to retain each document's local path, traversal depth and extracted outgoing links. The crawler could then reconstruct its frontier from previous state and re-extract when necessary.

I eventually moved document processing onto a bounded ThreadPoolExecutor since this shaved time off (I self-limited all network requests just as a safety precaution). As another safety precaution: downloads and PDF parsing could proceed concurrently, while locks protected shared state such as the processing set, work queue, statistics and persistence file. (with traversal batched rather than simply spawning work, concurrency was controllable through a worker param).

Some unsuccessful document requests returned non-PDF responses or application-level JSON errors. I added content validation using the PDF magic bytes and parsed structured error bodies, separating “document not found” from generic failures.

That made failed IDs inspectable; interestingly a lot of the failed IDs were simply a result of Barclay’s internal migration to a new format somewhere in 2024. Pre-2024 docIDs and post-2024 differed vastly. Once I realised the problem was in a changed format, I was able to go to the portal to monitor the behavior of opening a pre-2024 document which gave me the logic for finding the new migrated docIDs from the same.

The final system is therefore a resumable graph crawler over a document corpus. Given one seed publication, it discovers the surrounding research network, parallelizes expensive I/O and has been very helpful in building me a 150k document corpus.

If someone from Barclay’s is reading this, I did my part. I kept my corpus for myself, wrote you guys an in-depth email about 2 simple fixes which would just about fix everything, yet a year later I can still crawl your docs. So just keep that in mind before contacting me.

ABOUT THE AUTHOR

Rudraansh Tripathi. Big fan of everyone bringing sci-fi to life, trying to just be like that everyday.

FOLLOW

Follow on X →
Archive: all entries as plain text