更新:请,如果有人可以提供帮助:谷歌正在等待他们的错误跟踪工具上的输入和此问题的示例.如果您有针对此问题的可重现步骤,请分享:https://code.google.com/p/googleappengine/issues/detail?id = 10937
我正在尝试使用Google App Engine后端从StackExchange API获取数据.您可能知道,StackExchange的某些API是特定于站点的,要求开发人员针对用户注册的每个站点运行查询.
所以,这是我从这些网站获取时间线数据的后端代码.该feed_info_site变量保存StackExchange站点名称(如'security','serverfault'等).
data = json.loads(urllib.urlopen("%sme/timeline?%s" %
(self.API_BASE_URL, urllib.urlencode({"pagesize": 100,
"fromdate": se_since_timestamp, "filter": "!9WWBR
(nmw", "site": feed_info_site, "access_token":
decrypt(self.API_ACCESS_TOKEN_SECRET, self.access_token), "key":
self.API_APP_KEY}))).read())
for item in data['items']:
... # code for parsing timeline items
Run Code Online (Sandbox Code Playgroud)
在除Stack Overflow之外的所有站点上运行此查询时,一切正常.有点奇怪的是,当feed_info_site变量设置为时'stackoverflow',我从Google App Engine收到以下错误:
HTTPException: Invalid and/or missing SSL certificate for URL:
https://api.stackexchange.com/2.2/me/timeline?
filter=%219WWBR%28nmw&access_token=
<ACCESS_TOKEN_REMOVED>&fromdate=1&pagesize=100&key=
<API_KEY_REMOVED>&site=stackoverflow
Run Code Online (Sandbox Code Playgroud)
当然,如果我在Safari中运行相同的查询,我会得到我期望从API获得的JSON结果.所以问题实际上在于Google的URLfetch服务.我在Stack Overflow上发现了几个与类似的HTTPS/SSL异常相关的主题,但没有接受的答案解决了我的问题.我试过删除cacerts.txt文件.我也试过打电话validate_certificate=False,没有成功.
我认为问题与HTTPS/SSL并不严格相关.如果是这样,您如何解释更改单个API参数会导致请求失败?
我花了一整天的时间在Python中寻找最简单的多线程URL提取器,但我发现的大多数脚本都使用队列或多处理或复杂的库.
最后我自己写了一个,我作为答案报告.请随时提出任何改进建议.
我想其他人可能一直在寻找类似的东西.
python multithreading callback urlfetch python-multithreading
我正在尝试使用Google Scripts UrlFetchApp来访问具有基本用户名和密码的网站.一旦我连接到该站点,就会出现需要身份验证的弹出窗口.我知道登录名和密码,但我不知道如何在UrlFetchApp中传递它们.
var response = UrlFetchApp.fetch("htp://00.000.000.000:0000 /");
Logger.log(response.getContentText( "UTF-8"));
当前运行该代码返回"拒绝访问".出于安全原因,上面的代码不包含我要连接的实际地址.代码示例中的所有"http"都缺少"t",因为它们被检测为链接,而Stackoverflow不允许我提交两个以上的链接.
如何将登录名和密码与我的请求一起传递?无论如何我还可以在登录后继续我的会话吗?或者我的下一个UrlFetchApp请求是否会从另一台要求我再次登录的Google服务器发送?
这里的目标是登录Googles网络基础架构背后的网站,以便它可以充当代理,然后我需要向相同的地址发出另一个UrlFetchApp请求,如下所示:
var response = UrlFetchApp.fetch("htp://00.000.000.000:0000/vuze/rpc?json = {"method":"torrent-add","arguments":{"filename":"htp:// vodo达网络/媒体/种子/ anything.torrent " "下载-DIR": "C:\ TEMP"}}");
Logger.log(response.getContentText( "UTF-8"));
login credentials basic-authentication urlfetch google-apps-script
我想使用URLFetch服务在Google App Engine应用中打开HTTPS连接.为了能够验证我的应用正在与之交谈的服务器的SSL证书,我使用自己的密钥库文件.我想在加载我的应用程序时,即在执行任何HTTPS请求之前,在预热请求中读取此文件.密钥库文件是我的WAR文件的一部分.
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(ClassLoader.getSystemResourceAsStream("myKeystoreFile"), "password".toCharArray());
trustManagerFactory.init(keystore);
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustManagers, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
Run Code Online (Sandbox Code Playgroud)
但是,我不能使用这种方法,因为虽然HttpURLConnection在GAE的JRE白名单上,但HttpsUrlConnection却没有.
还有另一种在GAE中使用自定义密钥库的方法吗?我在GAE文档中没有找到任何相关信息.看起来,当Google的URLFetch服务支持HTTPS时,无法自定义密钥库.它是否正确?
如果这是不可能的,那么这种方法一般是否仍然有效?或者是否有一种不同的方法仍然允许我验证SSL证书?
UPDATE
2009年,谷歌的App Engine开发者Nick Johnson在https://groups.google.com/d/topic/google-appengine-python/C9RSDGeIraE/discussion上说:
urlfetch API不允许您指定自己的客户端证书,因此很遗憾您目前无法实现所需的目标.
这仍然是正确的吗?如果App Engine中的每个HTTP(s)请求都依赖于URLFetch,这意味着GAE中根本无法使用自定义证书.
我有一个Google AppEngine应用程序,它在我的本地计算机上运行良好.该应用程序将图像(从网址)发布到我的Facebook墙上.但是,当我将其部署到Google的服务器时,我收到一个错误:
DeadlineExceededError: Deadline exceeded while waiting for HTTP response from URL:
Run Code Online (Sandbox Code Playgroud)
违规代码是:
facebook_access_token = facebook_info['access_token']
facebook_post_url = 'https://graph.facebook.com/me/photos?access_token=%s&url=%s&name=%s&method=post' % (facebook_access_token, url, caption)
facebook_post_url = facebook_post_url.replace(" ", "+");
facebook_result = urlfetch.fetch(facebook_post_url)
if facebook_result.status_code == 200:
facebook_result_object = json.loads(facebook_result.content)
output_ids['facebook'] = facebook_result_object['id']
else:
output_ids['facebook'] = ''
Run Code Online (Sandbox Code Playgroud)
Ans完整的错误跟踪是:
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 710, in __call__
handler.get(*groups)
File "/base/data/home/apps/s~digibackapi/1.362663258877230387/main.py", line 512, in get
facebook_result = urlfetch.fetch(facebook_post_url)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/urlfetch.py", line 266, in fetch
return rpc.get_result()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 604, in …Run Code Online (Sandbox Code Playgroud) 在用 Python 编写的 Google App Engine (GAE) 上。
我正在尝试向 cloud-speech-to-text api 发布 http 帖子并使用 URI 音频源(Google Cloud Storage Bucket Objects)。
我正在使用以下标题;
Authorization: BASIC encoded_base64(username:password)
Run Code Online (Sandbox Code Playgroud)
但我仍然不断收到以下错误响应:
{ "error": { "code": 403, "message": "匿名来电者没有 storage.objects.get 访问 bucket_of_secrets/four_score_seven_years.flac.", "status": "PERMISSION_DENIED" } }
所以我有几个问题;
username:password应该使用什么?是我的 GCP 帐户电子邮件和密码吗?IEhandsome_dude@gmail.com:deluded_fool哪里handsome_dude@gmail.com是用户名,哪里是deluded_fool密码。
我已经尝试将存储桶对象设置为公共可读,当然 http 调用有效……但我宁愿避免将存储桶对象设置为公共可读。
这是一个示例 Curl 请求:
curl -X POST
https://speech.googleapis.com/v1/speech:longrunningrecognize?key=<secret_api_key> -d @sample.json -H "Content-Type: application/json, Authorization: Basic base64encodedusername:password"
Run Code Online (Sandbox Code Playgroud)
这是我使用 urlfetch 的 …
google-app-engine http-headers urlfetch google-cloud-storage google-cloud-platform
我想知道Google App Engine 网址提取Python API是否不支持访问具有凭据的网址:
http://username:password@www.domain.com/
Run Code Online (Sandbox Code Playgroud)
它应该是一个基本功能,但我无法让它工作,也找不到任何有关它支持或不支持的文档.
我想使用urlfetch来填充包含页面数据的电子表格,但我尝试使用的URL会返回错误作为无效参数.我认为问题是我在URL中使用了被误解的字符(例如引号和括号).
我尝试使用下面的命令对URL进行编码,但我假设我对某些字符进行了双重编码,这导致了问题.
var encodedURL = encodeURIComponent(pageURL)
Run Code Online (Sandbox Code Playgroud) 我在 Google Apps Script 中有以下代码,它使用基本身份验证通过 HTTP 从网页中检索 CSV 数据并将其放入电子表格中:
CSVImport.gs
function parseCSVtoSheet(sheetName, url)
{
// Credentials
var username = "myusername";
var password = "mypassword";
var header = "Basic " + Utilities.base64Encode(username + ":" + password);
// Setting the authorization header for basic HTTP authentication
var options = {
"headers": {
"Authorization": header
}
};
// Getting the ID of the sheet with the name passed as parameter
var spreadsheet = SpreadsheetApp.getActive();
var sheet = spreadsheet.getSheetByName(sheetName);
var sheetId = sheet.getSheetId();
// …Run Code Online (Sandbox Code Playgroud) 阅读异步URL抓取的Google App Engine 文档:
该应用最多可同时拥有10个异步URL提取呼叫
如果应用程序一次调用10个以上的异步提取,会发生什么?
Google App Engine是否会引发异常,或者只是将剩余呼叫排队等待为其提供服务?
urlfetch ×10
python ×3
credentials ×2
asynchronous ×1
callback ×1
http-headers ×1
https ×1
java ×1
javascript ×1
keystore ×1
login ×1
ssl ×1