lotto results

Thursday, April 27, 2023

[New post] I want to check out how to do POST requests using bookmarklets in order to save URLs to the WayBack machine

Site logo image jpluimers posted: "I want to check out how to do POST requests using bookmarklets in order to save URLs to the Wayback machine. The reason is that every few months or so, saving a page the normal way through a something like https://web.archive.org/save/URL fails for one r" The Wiert Corner - irregular stream of stuff

I want to check out how to do POST requests using bookmarklets in order to save URLs to the WayBack machine

jpluimers

Apr 27

I want to check out how to do POST requests using bookmarklets in order to save URLs to the Wayback machine.

The reason is that every few months or so, saving a page the normal way through a something like https://web.archive.org/save/URL fails for one reason or the other, but going to https://web.archive.org/save, then entering URL, and pressing "SAVE PAGE" button works fine:

  • [Archive] Jeroen Wiert Pluimers on Twitter: "Does anyone why the @waybackmachine has a lot of job failed and 404 errors over the last few days? ... and ... just returned a 404; most of my archivals the last few days failed or had to be retried at least half a dozen times to succeed. ..." / Twitter
  • [Archive] Jeroen Wiert Pluimers on Twitter: "Workaround - still slow, but at least succeeds sometimes: ... then enter the URL to be archived." / Twitter
  • [Archive] Jeroen Wiert Pluimers on Twitter: "Workaround now consistently fails for https://t.co/ruKnfWlfJ0 Is here a @waybackmachine status page somewhere?" / Twitter

The the failing way above is using a GET request, the succeeding workaround will open https://web.archive.org/save/URL  using the below POST request (where I omitted some HTTP cookies and HTTP header fields for brevity).

  • POST request using PowerShell:
    $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession $session.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36" Invoke-WebRequest -UseBasicParsing -Uri "https://web.archive.org/save/URL" ` -Method "POST" ` -WebSession $session ` -Headers @{ "method"="POST"   "origin"="https://web.archive.org"   "referer"="https://web.archive.org/save" } ` -ContentType "application/x-www-form-urlencoded" ` -Body "url=URL&capture_outlinks=on&capture_all=on&capture_screenshot=on"
  • POST request using cURL on bash:
    curl 'https://web.archive.org/save/URL' \   -H 'origin: https://web.archive.org' \   -H 'content-type: application/x-www-form-urlencoded' \   -H 'referer: https://web.archive.org/save' \   --data-raw 'url=URL&capture_outlinks=on&capture_all=on&capture_screenshot=on' \   --compressed
  • POST request using the fetch API in JavaScript:
    fetch("https://web.archive.org/save/URL", {   "headers": {     "content-type": "application/x-www-form-urlencoded",   },   "referrer": "https://web.archive.org/save",   "body": "url=URL&capture_outlinks=on&capture_all=on&capture_screenshot=on",   "method": "POST",   "mode": "cors" });

BTW: Yes, I know that URL is not a valid URL, so it will return a page with "http://url/ URL syntax is not valid.".

All links below via [Wayback/Archive] bookmarklet post request - Google Search:

  • [Wayback/Archive] GlenCoakley/createFormSubmittingBookmarklets: Scans through the current web page finding all forms. It will open a new window that listing all of them along with the source for a bookmarklet that will submit that form with its current data.
    • [Wayback/Archive] createFormSubmittingBookmarklets/createFormSubmitBookmarklets.js at master · GlenCoakley/createFormSubmittingBookmarklets
  • [Wayback/Archive] bookmarklet maker by tac (takes a piece of JavaScript, removes spaces, generates bookmarklet anchor which you can drag to your bookmarks)
    • Source saved at [Archive] https://gist.github.com/jpluimers/893699a4dd287c1c5b76f50cd2b7f7e5
  • Though I really dislike minified code, for a bookmarklet it is often the easiest way to keep it short, so:
    • Page wrapper: [Wayback/Archive] UglifyJS 3: Online JavaScript minifier
    • Source: [Wayback/Archive] Skalman/UglifyJS-online: JavaScript minifier in the browser
  • [Wayback/Archive] How to save a bookmark in Firefox with POST data? - Super User
  • [Wayback/Archive] google chrome - Storing a HTTP POST request in a bookmark or something similar as you would with a GET request - Super User
  • [Wayback/Archive] Javascript bookmarklet with POST command - Stack Overflow
  • [Wayback/Archive] How to Add a Cross-Browser Bookmark Button to Your Website | The Web Flash
  • [Wayback/Archive] Javascript to add a bookmark - Cross Browser

I tried to put createFormSubmittingBookmarklets/createFormSubmitBookmarklets.js in a bookmarklet using both userjs.up.seesaa.net/js/bookmarklet.html and skalman.github.io/UglifyJS-online. That failed: somehow this code does not want to run as bookmarklet.

Running it from the console is fine though, and gave me this basic bookmarklet template:

javascript:function sf(ur,ty,fd){function me(tg,pr){var el=document.createElement(tg);for(const[nm,vl]of Object.entries(pr)){el.setAttribute(nm,vl);}return el}const fm=me("form",{action:ur,method:ty,style:"display:hidden;"});for(const[nm,vl]of Object.entries(fd)){fm.appendChild(me("input",{name:nm, value:vl}))}document.body.appendChild(fm);fm.submit()}sf("https://web.archive.org/save","post",{"url":"URL","capture_outlinks":"on","capture_all":"on","capture_screenshot":"on","wm-save-mywebarchive":"on","email_result":"on","":"SAVE PAGE"});

There bold URL there is the URL to be saved. I need to test this, then rework it to become parameterised.

--jeroen

Comment
Like
Tip icon image You can also reply to this email to leave a comment.

Unsubscribe to no longer receive posts from The Wiert Corner - irregular stream of stuff.
Change your email settings at manage subscriptions.

Trouble clicking? Copy and paste this URL into your browser:
http://wiert.me/2023/04/27/i-want-to-check-out-how-to-do-post-requests-using-bookmarklets-in-order-to-save-urls-to-the-wayback-machine/

WordPress.com and Jetpack Logos

Get the Jetpack app to use Reader anywhere, anytime

Follow your favorite sites, save posts to read later, and get real-time notifications for likes and comments.

Download Jetpack on Google Play Download Jetpack from the App Store
WordPress.com on Twitter WordPress.com on Facebook WordPress.com on Instagram WordPress.com on YouTube
WordPress.com Logo and Wordmark title=

Learn how to build your website with our video tutorials on YouTube.


Automattic, Inc. - 60 29th St. #343, San Francisco, CA 94110  

at April 27, 2023
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Reminder: North America Sees Slight Increase in Weighted Fiber Prices

  North America Sees Slight Increase in Weighted Fiber Prices ATH...

  • [New post] Tony Bennett Ft. Lady Gaga – You’re The Top
    Ayonline posted: " American singer, Tony Bennett come through with a new song title You're The Top Feat. Lady Gaga ...
  • [New post] The Z Blog: Money Matters
    sengssk posted: "A favorite expression is "pressure reveals character." Anyone who has played sports has probably...
  • [New post] Former Isidingo actress Kim Engelbrecht gets a nod from the 2022 Emmy Awards
    Porti...

Search This Blog

  • Home

About Me

lotto result
View my complete profile

Report Abuse

Blog Archive

  • June 2025 (3)
  • May 2025 (2)
  • March 2025 (5)
  • February 2025 (3)
  • January 2025 (4)
  • December 2024 (2)
  • November 2024 (1)
  • October 2024 (3)
  • September 2024 (4)
  • June 2023 (176)
  • May 2023 (1209)
  • April 2023 (1076)
  • March 2023 (1208)
  • February 2023 (912)
  • January 2023 (998)
  • December 2022 (1022)
  • November 2022 (1082)
  • October 2022 (1580)
  • September 2022 (1476)
  • August 2022 (1694)
  • July 2022 (1786)
  • June 2022 (1251)
  • May 2022 (1056)
  • April 2022 (1443)
  • March 2022 (1328)
  • February 2022 (1092)
  • January 2022 (1332)
  • December 2021 (1657)
  • November 2021 (3162)
  • October 2021 (3225)
  • September 2021 (3171)
  • August 2021 (3282)
  • July 2021 (1390)
Powered by Blogger.