Search in gist only #179806
Replies: 3 comments
-
|
GitHub does not provide a public Search API for Gists. To find Gists you have two practical options: Scrape the Gist web search (https://gist.github.com/search?q=...) — quick and simple but unofficial and brittle. Index public gists yourself by pulling /gists/public (paginated) and searching your local index — reliable but heavier. Below I show example commands / code for both approaches and the pros/cons so you can pick. Option A — Quick (unofficial) — scrape the Gist search page The Gist web UI supports queries like https://gist.github.com/search?q=CVE-2. You can request that URL and parse the HTML to extract matching gist links. Example (Python + requests + BeautifulSoup): Requires: pip install requests beautifulsoup4import requests q = "CVE-2" soup = BeautifulSoup(resp.text, "html.parser") gist links on search results are anchors with href like //links = [] print unique matchesfor l in sorted(set(links)): Pros Simple and fast to implement. Finds the exact Gist web search results (same as what you see in a browser). Cons Unofficial — GitHub can change the HTML or block scraping. May violate GitHub TOS if abused; pay attention to rate limits and politeness. |
Beta Was this translation helpful? Give feedback.
-
|
you can’t use the GitHub Search API (v3) to search gists as you do repos — there is no “search gists” endpoint. Here’s more detail and some possible workarounds |
Beta Was this translation helpful? Give feedback.
-
|
How do I submit a feature request to support this? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
I'm using github search api to find relevant code or repo. But it works on repo only, how can I search gist only?
e.g by searching "CVE-2", I'm expecting to find https://gist.github.com/N3mes1s/d882ee7ca4ddcad150f94b7460508a32
Beta Was this translation helpful? Give feedback.
All reactions