netgo
A lightweight Python toolkit for scraping search engines and getting the links back, and for talking to the Wikimedia APIs.
netgo exposes a single, engine-agnostic API on top of several search
backends, so you can switch or combine engines without touching your
data model. Every backend returns the same netgo.Result objects,
ranked by the engine.
On the Wikimedia side, netgo.wiki wraps the MediaWiki Action API
behind one shared WikiClient session: Wikipedia search and article
structure, Wikidata entities and facts, Wikimedia Commons files and
Wiktionary definitions.
Search backends
- Google — the default.
- Bing — selected with
engine="bing".
Wikimedia APIs
- Wikipedia — full-text search, summaries, paragraphs, sections, links, backlinks, categories, images, random pages, geo search.
- Wikidata — titles → QIDs, entities, label search, claims, aliases, sitelinks, raw SPARQL.
- Wikimedia Commons — image search, file URLs, thumbnails, licences.
- Wiktionary — definitions, etymology, languages of a word.
Page reading
netgo.fetch— download any web page and get back just its main content, with the site template (nav, headers, footers, sidebars, banners) filtered out.
When a search page is throttled or blocked, netgo raises SearchBlockedError
instead of silently returning nothing, so automation can detect and react.
Install
pip install git+https://github.com/FrancoFantomius/netgo.git
Requires Python 3.9+.
Getting started
import netgo
# Google (default), num results per page
results = netgo.search("python web scraping", num=10)
# Bing, same interface
results = netgo.search("python web scraping", num=10, engine="bing")
for r in results:
print(r.position, r.title)
print(" ", r.url)
print(" ", r.snippet[:80])
Run several queries in parallel:
out = netgo.search_many(["cats", "dogs"], max_workers=4, num=5)
for query, results in out.items():
print(query, [r.url for r in results])
Viewing a page
Fetch any URL and read just its real content; the site template (navigation, headers, footers, sidebars, banners, comment widgets) is filtered out:
import netgo
page = netgo.fetch("https://www.bbc.co.uk/news/science-environment-56837908")
print(page.title) # "Climate change: Biggest..."
print(page.site) # "bbc.co.uk"
print(page.paragraphs[:3])
netgo.fetch returns a Page with the extracted title, domain, cleaned
plain-text body (text and paragraphs), the content HTML and the raw
HTML as the server sent it (raw). PageError
is raised for transport failures (PageFetchError) or pages with no
readable content (PageParseError), so automation can detect and react.
Sitemaps
Discover, parse and crawl XML sitemaps (URL sets, sitemap indexes and plain-text sitemaps):
import netgo
# Sitemaps a site declares in its robots.txt
urls = netgo.sitemap.discover("https://www.example.com")
# View a single sitemap, and every URL it announces
sm = netgo.sitemap.load("https://www.example.com/sitemap.xml")
print(sm.kind) # "urlset" | "sitemapindex" | "text"
for entry in sm: # SitemapEntry with loc/lastmod/...
print(entry.loc)
# Follow a sitemap index down to every page URL across all children
pages = netgo.sitemap.crawl("https://www.example.com/sitemap_index.xml")
# Every page whose URL starts with a given prefix (page_1, page_2, ...)
paged = netgo.sitemap.filter_by_prefix(
"https://www.example.com/sitemap_index.xml",
"https://www.example.com/page_",
)
# Or filter a sitemap you already loaded
subset = sm.by_prefix("https://www.example.com/page_")
parse handles raw content without the network (namespace-agnostic, resolves
relative locations), load also unpacks gzip-compressed sitemaps, and
SitemapError subclasses (SitemapFetchError, SitemapParseError) make
failures detectable.
Wikipedia APIs
import netgo.wiki as wiki
# Wikipedia: full-text search and article structure
hits = wiki.search("python programming", limit=5)
for h in hits:
print(h.title, h.wordcount)
lead = wiki.summary("Bread", sentences=2)
paras = wiki.paragraphs("Bread")
toc = wiki.sections("Bread")
near = wiki.geo_search(41.89, 12.49, radius=2000, limit=5)
# Wikidata: resolve a title to its QID and read its facts
qid = wiki.wikidata_id("Bread")
item = wiki.entity(qid, language="en")
print(item.labels["en"], item.claims.get("P279", []))
# Wikidata: raw SPARQL (default query returns items with a P624 guidance system)
rows = wiki.sparql(language="en")
print(rows[0]["itemLabel"], rows[0]["guidanceSystemLabel"])
# Wikimedia Commons: find files and their metadata
files = wiki.search_images("sunflower", limit=3)
meta = wiki.file_info(files[0].name)
# Wiktionary: dictionary data
entry = wiki.wiktionary_definition("serendipity")
print(entry.pos, entry.definitions)
Every function accepts lang= to pick a Wikipedia/Wiktionary edition,
reuses a shared WikiClient session, and raises WikiError subclasses
(WikiAPIError, WikiNotFoundError) on failure.
Examples
Runnable, end-to-end scripts that use the library against the live network
live in examples/, covering search engines, page reading and
each Wikimedia API:
python examples/01_search.py
python examples/08_research_pipeline.py
See examples/README.md for the full list.
Documentation
The documentation is hosted at francofantomius.com/netgo/.
The documentation is built with VitePress and generated directly from Python docstrings. To regenerate the documentation files locally:
python scripts/generate_docs.py
To run the VitePress documentation server locally:
npm install
npm run docs:dev
Notes
- This scrapes public search-engine result pages. Engines may throttle or
block requests from datacenter IPs; add
delaybetween calls, or use the alternate engine when one is blocked. - The Wikimedia APIs are public and free, but be polite: reuse a single
WikiClient, keepdelayfor batch loops, and set a descriptiveUser-Agent(seenetgo/wiki/client.py). - Check each engine's terms of service for your use case.
Metadata
Release files for netgo 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| netgo-0.4.1.tar.gz | 54.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| netgo-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 110.5 kB
Release files / netgo-0.4.1.tar.gz
| Download URL | netgo-0.4.1.tar.gz |
|---|---|
| Size | 54.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0159c9e0e4f9dcc6b7bcf27a1673bfcbae666a046388c068d714cba67d62c87
|
|
BLAKE2b-256 checksum How to use checksums |
c8f2fec00e79a616655b95799453a915a9f52ad9f533787e620a4357daebb781
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / netgo-0.4.1-py3-none-any.whl
| Download URL | netgo-0.4.1-py3-none-any.whl |
|---|---|
| Size | 55.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
72ada604fa0c9b2688c333c1ee230805a81126f844267955c4f314b71944b53a
|
|
BLAKE2b-256 checksum How to use checksums |
d4c79cd4b4e15d7a541c34a0e6b2fcea4667ab5ec5c4a37e2ac8ce1201238b7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency log