How to fetch a wordpress admin page using google apps script?

There might be an issue with Google Apps Scripts and post-ing to a URL that gives you back a redirection header. It seems like it might not be possible to follow the redirect with a post – here’s a discussion on the issue – https://issuetracker.google.com/issues/36754794 Would it be possible, if you modify your code to … Read more

How to convert a Google Sheets-File to an Excel-File (XLSX)

Using the Drive API, we can get more information about files than is available through the DriveApp methods. Check out the file data, especially exportLinks. Those links contain the magic that will let us get an XLS file. (For fun, put a breakpoint after file is assigned, and check what information you have to play … Read more

Create a post in Blogger with Google Apps Script

Required reading: ScriptApp#getOauthToken Blogger §post#insert UrlFetchApp#fetch Editing manifest#Setting explicit scopes Switch to standard GCP API Library Issue: Usage of asynchronous client side browser samples in the synchronous server side. Solution: It is possible to access Blogger api from Google apps script using UrlFetchApp Full OAuth flow can be bypassed using oauth token provided by ScriptApp … Read more

UrlFetchApp request fails in Menu Functions but not in Custom Functions (connecting to external REST API)

When UrlFetchApp is used by the custom function and the script editor, I think that the difference is whether IPv6 is used, while the address of IPv4 is changed every run. In this case, the results of the script editor and custom menu are the same. I thought that this might be the reason of … Read more

Cookie handling in Google Apps Script – How to send cookies in header?

Here you can find cookies specification: http://www.w3.org/Protocols/rfc2109/rfc2109 You have a potential issue in your code: response.getAllHeaders()[‘Set-Cookie’] can return either a string or a table of string if multiple ‘set-cookie’ attributes are sent back from the server. Eric is right, you cannot return the cookie without digesting it. Second error in your code: var opt2 = … Read more

How to use UrlFetchApp with credentials? Google Scripts

This question has been answered on another else where. Here is the summary: Bruce Mcpherson basic authentication looks like this… var options = {}; options.headers = {“Authorization”: “Basic ” + Utilities.base64Encode(username + “:” + password)}; Lenny Cunningham //Added Basic Authorization////////////////////////////////////////////////////////////////////////////////////////// var USERNAME = PropertiesService.getScriptProperties().getProperty(‘username’); var PASSWORD = PropertiesService.getScriptProperties().getProperty(‘password’); var url = PropertiesService.getScriptProperties().getProperty(‘url’);//////////////////////////Forwarded Ports to WebRelay … Read more

A very simple multithreading parallel URL fetching (without queue)

Simplifying your original version as far as possible: import threading import urllib2 import time start = time.time() urls = [“http://www.google.com”, “http://www.apple.com”, “http://www.microsoft.com”, “http://www.amazon.com”, “http://www.facebook.com”] def fetch_url(url): urlHandler = urllib2.urlopen(url) html = urlHandler.read() print “‘%s\’ fetched in %ss” % (url, (time.time() – start)) threads = [threading.Thread(target=fetch_url, args=(url,)) for url in urls] for thread in threads: thread.start() … Read more