Google Sheets

The search in a spreadsheet: a formula that lists the websites whose page source contains a fragment of code, and a menu that exports a whole query to a new sheet. Free to copy, runs with your API token.

=PUBLICWWW(A1)                    websites whose page source contains the query in A1
=PUBLICWWW(A1, 50, "url,rank")    50 rows, only the url and rank columns
=PUBLICWWW_COUNT(A1)              how many websites match

Setting it up

  1. Open a spreadsheet, then Extensions > Apps Script.
  2. Replace the contents of Code.gs with Code.gs from the repository and save.
  3. Reload the spreadsheet. A PublicWWW menu appears; choose Set API token and paste a token from your profile page. The API needs a paid plan.
  4. Google asks once to authorize the script: it reads and writes this spreadsheet only, and connects to api.publicwww.com.

The token is kept in the script's properties, so anyone who can edit this spreadsheet's script can read it. Share edit access accordingly, or give the spreadsheet a token of its own that you can delete on the profile page.

Writing the query

The query is the same as in the search box - see query syntax. Quotes matter: "angular.min.js" with the quotes is that exact string, without them it is several words. Inside a formula a quote is written twice, =PUBLICWWW("""angular.min.js"""), so it is easier to type the query, quotes included, into a cell and refer to it: =PUBLICWWW(A1).

The functions

A formula runs a search when it is entered or its arguments change, and an answer is kept for six hours, so reopening the sheet does not spend searches again. Each new formula is one search from the plan's daily quota.

Exporting a whole query

PublicWWW > Export a query to a new sheet writes every row your plan covers for the query into a new sheet, with the totals in a note on its first cell. A very large export can run into Google's limit of six minutes per script run; for lists of hundreds of thousands of rows, ask the API directly - format=csv opens in any spreadsheet.

When a cell says #ERROR!

Hover over the cell for the reason.

ReasonWhat to do
No API token yetPublicWWW > Set API token.
invalid_keyThe token was deleted; set a new one.
plan_requiredThe API needs a paid plan.
too_many_requestsMore than 10 requests a minute; wait the seconds shown.
quota_exceededThe day's searches are used up; they reset at midnight UTC.

All codes: Errors.

Next Clay