Saves the text of a web page into a new Google Doc, even when the site won't hand its text to anything but a browser.
Uses
Google Docs
Jina AI
Save a hard-to-open web page as a Google Doc
Give it the address of a page that will not hand its text to anything but a browser, and run it whenever you need one read. A plain request is tried first, and only if that comes back blocked, too short or as a challenge screen is the address read through a reader service that renders it properly. Either way the text lands in a new Google Doc.
You get a document titled after the page, opening with the source address and which route the text came by, followed by the readable text. Each run creates its own document, so nothing you already have is overwritten. The address recorded is rebuilt from the scheme, host and path only: the query string, where an access key travels, is left out, and a failed request is reported by host and reason alone. If neither route produces any text, the run stops rather than saving an empty document.
Use it on pages you are entitled to read: it is for getting at an article you could open yourself in a browser, not for reaching anything you could not.
pageUrl to blank.Set pageUrl to blank.minimumCharacters to 600.Set minimumCharacters to 600.maximumCharacters to 20000.Set maximumCharacters to 20000.pageUrl split by ://[1] and save it as afterScheme.Trim pageUrl split by ://[1] and save it as afterScheme.afterScheme by / and save it as hostAndPath.Split afterScheme by / and save it as hostAndPath.hostAndPath and save it as authorityPart.Trim the first item of hostAndPath and save it as authorityPart.authorityPart split by @ and save it as pageHost.Trim the last item of authorityPart split by @ and save it as pageHost.pageHost is empty or pageHost is nullIf pageHost is empty or pageHost is nullhostAndPath with / and save it as pagePath.Join the items from index 1 onward of hostAndPath with / and save it as pagePath.pagePath split by ? and save it as pagePath.Get the first item of pagePath split by ? and save it as pagePath.pagePath split by # and save it as pagePath.Get the first item of pagePath split by # and save it as pagePath.pageScheme to http://.Set pageScheme to http://.pageUrl starts with https://If pageUrl starts with https://pageScheme to https://.Change pageScheme to https://.sourceLabel to pageScheme plus pageHost.Set sourceLabel to pageScheme plus pageHost.pagePath isn't emptyIf pagePath isn't emptysourceLabel to sourceLabel/pagePath.Change sourceLabel to sourceLabel/pagePath.directBody to blank.Set directBody to blank.directOk to false.Set directOk to false.directNote to blank.Set directNote to blank.fetchErrorIf a step below fails, save the error as fetchErrorpageUrl and save it as response.Fetch pageUrl and save it as response.response.body and save it as directBody.Trim response.body and save it as directBody.directOk to response.ok is true.Change directOk to response.ok is true.directNote to A plain request to pageHost answered with status response.status.Change directNote to A plain request to pageHost answered with status response.status.fetchError.message and save it as rawReason.Trim fetchError.message and save it as rawReason.directNote to A plain request to pageHost failed: rawReason with pageUrl replaced by the address you gave.Change directNote to A plain request to pageHost failed: rawReason with pageUrl replaced by the address you gave.directOk to false.Change directOk to false.directNote contains ://If directNote contains ://directNote to A plain request to pageHost could not be completed.Change directNote to A plain request to pageHost could not be completed.minimumLength to minimumCharacters multiplied by 1.Set minimumLength to minimumCharacters multiplied by 1.looksBlocked to false.Set looksBlocked to false.directOk is noIf directOk is nolooksBlocked to true.Change looksBlocked to true.directBody is less than minimumLengthIf the length of directBody is less than minimumLengthlooksBlocked to true.Change looksBlocked to true.directBody contains just a moment (ignoring case)If directBody contains just a moment (ignoring case)looksBlocked to true.Change looksBlocked to true.directBody contains enable javascript (ignoring case)If directBody contains enable javascript (ignoring case)looksBlocked to true.Change looksBlocked to true.directBody contains captcha (ignoring case)If directBody contains captcha (ignoring case)looksBlocked to true.Change looksBlocked to true.directBody contains access denied (ignoring case)If directBody contains access denied (ignoring case)looksBlocked to true.Change looksBlocked to true.directBody contains attention required (ignoring case)If directBody contains attention required (ignoring case)looksBlocked to true.Change looksBlocked to true.directBody contains verify you are human (ignoring case)If directBody contains verify you are human (ignoring case)looksBlocked to true.Change looksBlocked to true.directBody contains are you a robot (ignoring case)If directBody contains are you a robot (ignoring case)looksBlocked to true.Change looksBlocked to true.readableText to blank.Set readableText to blank.pageTitle to blank.Set pageTitle to blank.readVia to blank.Set readVia to blank.looksBlocked is yesIf looksBlocked is yesreaderErrorIf a step below fails, save the error as readerErrorpageUrl with Jina. Save it as reader.Read the page at pageUrl with Jina. Save it as reader.reader.content and save it as readableText.Trim reader.content and save it as readableText.reader.title and save it as pageTitle.Trim reader.title and save it as pageTitle.pageHost. Check the address, and check you are able to open the page yourself.Stop and report a problem: Neither a plain request nor the reader service could get the text of that page on pageHost. Check the address, and check you are able to open the page yourself.readVia to Read through the reader service, because the plain request did not come back with the page..Change readVia to Read through the reader service, because the plain request did not come back with the page..readableText to directBody.Change readableText to directBody.readVia to Read with a plain request. The reader service was not needed..Change readVia to Read with a plain request. The reader service was not needed..readableText is nullIf readableText is nullreadableText to blank.Change readableText to blank.readableText is emptyIf readableText is emptypageHost came back with no readable text at all, so there was nothing to save.Stop and report a problem: That page on pageHost came back with no readable text at all, so there was nothing to save.documentTitle to pageHost.Set documentTitle to pageHost.pageTitle isn't empty and pageTitle is not nullIf pageTitle isn't empty and pageTitle is not nulldocumentTitle to pageTitle.Change documentTitle to pageTitle.documentTitle to 90 characters and save it as documentTitle.Shorten documentTitle to 90 characters and save it as documentTitle.document to nothing.Set document to nothing.documentId to blank.Set documentId to blank.documentErrorIf a step below fails, save the error as documentErrordocumentTitle. Save it as document.Create the document documentTitle. Save it as document.document.document_id and save it as documentId.Trim document.document_id and save it as documentId.documentId is empty or documentId is nullIf documentId is empty or documentId is nullheader to Source: sourceLabelSet header to Source: sourceLabel
readVia
.header to header@directNoteChange header to header@directNote
.documentText to header plus readableText truncated to a record of kind, op, left, and right characters.Set documentText to header plus readableText truncated to a record of kind, op, left, and right characters.documentId.Add text to documentId.documentTextpageHost to a new Google Doc.Show in the output: Saved the readable text of pageHost to a new Google Doc.