我正在尝试调用import.io API.此调用需要具有以下结构:
' https://extraction.import.io/query/extractor/ {{crawler_id}}?_ apikey = xxx&url = http://www.example.co.uk/items.php?sortby=Price_LH&per_page=96&size=1%2C12&page = 35 '
您可以在该调用中看到,还必须包含参数"url":
http://www.example.co.uk/items.php?sortby=Price_LH&per_page=96&size=1%2C12&page=35
恰好这个辅助URL也需要参数.但是,如果我将其作为普通字符串传递,如上例所示,API响应仅在我获得API响应时包含第一个参数之前的部分:
这是不正确的,似乎它将使用不完整的URL而不是我传入的URL进行调用.
我正在使用Python并请求以下列方式进行调用:
import requests
import json
row_dict = {'url': u'http://www.example.co.uk/items.php?sortby=Price_LH&per_page=96&size=1%2C12&page=35', 'crawler_id': u'zzz'}
url_call = 'https://extraction.import.io/query/extractor/{0}?_apikey={1}&url={2}'.format(row_dict['crawler_id'], auth_key, row_dict['url'])
r = requests.get(url_call)
rr = json.loads(r.content)
Run Code Online (Sandbox Code Playgroud)
当我打印reuslt时:
"url" : "http://www.example.co.uk/items.php?sortby=Price_LH",
Run Code Online (Sandbox Code Playgroud)
但是当我打印r.url时:
https://extraction.import.io/query/extractor/zzz?_apikey=xxx&url=http://www.example.co.uk/items.php?sortby=Price_LH&per_page=96&size=1%2C12&page=35
Run Code Online (Sandbox Code Playgroud)
所以在URL中它似乎都很好但不在响应中.
我尝试使用其他URL,并在第一个参数后切换.
我的目标是在我的 Windows 10 计算机上安装 fbprophet。我正在尝试使用 pip 安装 pystan (先知的主要依赖项),但大约一分钟后,我收到以下错误:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\User\appdata\local\temp\pip-build-nbypis\pystan\setup.py", line 124, in <module>
logger.warning("MSVC is not supported")
NameError: name 'logger' is not defined
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\User\appdata\local\temp\pip-build-nbypis\pystan\
Run Code Online (Sandbox Code Playgroud)
我正在使用 python 2.7
我编写了一个脚本来连接到Google电子表格并从中将数据加载到postgresql数据库中.我已经创建了一个服务帐户并以.json格式获取了必要的凭据,问题是当我尝试与我的服务帐户电子邮件共享Google工作表时,我收到一封电子邮件说:
完全无法传送给下列收件人:
Run Code Online (Sandbox Code Playgroud)dataload@geometric-shine-118101.iam.gserviceaccount.com永久性故障的技术细节:DNS错误:geometric-shine-118101.iam.gserviceaccount.com的地址解析.失败:找不到域名
该电子邮件与我在.json密钥文件中的电子邮件完全相同.我已经检查了其他帖子,通常应该共享的电子邮件的结构是这样的:
project_name@developer.gserviceaccount.com
Run Code Online (Sandbox Code Playgroud)
但我的不同,也许它与此有关?我按照此链接上的说明操作.
这是.json密钥文件的副本:
{
"type": "service_account",
"project_id": "geometric-shine-118101",
"private_key_id": "xxx",
"private_key": "-----BEGIN PRIVATE KEY-----\nxxx\n-----END PRIVATE KEY-----\n",
"client_email": "dataload@geometric-shine-118101.iam.gserviceaccount.com",
"client_id": "117076930343404252458",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/dataload%40geometric-shine-118101.iam.gserviceaccount.com"
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Python 和 urllib2 访问 Buxfer REST API。
问题是我得到以下回复:
urllib2.HTTPError: HTTP Error 403: Forbidden
Run Code Online (Sandbox Code Playgroud)
但是当我通过浏览器尝试相同的调用时,它工作正常......
脚本如下:
username = "xxx@xxxcom"
password = "xxx"
#############
def checkError(response):
result = simplejson.load(response)
response = result['response']
if response['status'] != "OK":
print "An error occured: %s" % response['status'].replace('ERROR: ', '')
sys.exit(1)
return response
base = "https://www.buxfer.com/api";
url = base + "/login?userid=" + username + "&password=" + password;
req = urllib2.Request(url=url)
response = checkError(urllib2.urlopen(req))
token = response['token']
url = base + "/budgets?token=" + token;
req = urllib2.Request(url=url) …Run Code Online (Sandbox Code Playgroud) 我想知道是否可以使用条件创建某种 session.merge(current_values) 。SQLAlchemy 替换现有记录(根据指定的 kwargs 作为键),但盲目地执行(并不是说它不好,只是我有一个单独的用例)。
仅当满足涉及数据库中当前现有值的给定条件时,是否可以执行 session.merge() ?
if database_value>current_value:
session.merge(current_value)
Run Code Online (Sandbox Code Playgroud) 我在 Windows 10 PC (Ubuntu 18.04) 上安装了 Windows 子系统 Linux。我在Windows上安装了Docker工具箱,并通过VM运行我可以通过设置正常运行docker命令:
export DOCKER_HOST=tcp://192.168.99.101:2376
Run Code Online (Sandbox Code Playgroud)
我可以很好地访问它并正确安装/运行 docker 容器。其中一项服务是在 localhost:8084 上运行的 Kafka Connect 容器,该容器是从我的 Windows 创建的。如果我直接从 Ubuntu 子系统运行它,我通常可以从 Windows 浏览器访问它,但是如果我从 Windows 子系统内的 docker 容器运行它,我将无法访问它,就好像端口没有从 docker 正确转发一样- 撰写文件。以下是运行该服务的配置:
#
# This docker-compose file starts and runs:
# * A 3-node kafka cluster
# * A 1-zookeeper ensemble
# * Schema Registry
# * Kafka REST Proxy
# * Kafka Connect
#
version: '3.7'
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.2.2
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: "2181"
kafka0:
image: …Run Code Online (Sandbox Code Playgroud) docker docker-compose windows-subsystem-for-linux apache-kafka-connect
我有一个包含名称列表的表,其中可能包含特殊字符:
id name
1 Johän
2 Jürgen
3 Janna
4 Üdyr
...
Run Code Online (Sandbox Code Playgroud)
是否存在将每个字符替换为另一个特定字符的功能?(未必是一个不加强调的人)。像这样:
SELECT id, function('ä,ü',name,'ae,ue');
Result:
id name
1 Johaen
2 Juergen
3 Janna
4 UEdyr
...
Run Code Online (Sandbox Code Playgroud) 我很难尝试将import.io中的API响应加载到文件或列表中.
我正在使用的是 https://data.import.io/extractor/{0}/json/latest?_apikey={1}
以前我的所有脚本都设置为使用普通的JSON,并且一切都运行良好,但现在嘿已经决定使用json线,但不知怎的,它似乎格格不入.
我尝试调整脚本的方法是以下列方式读取API响应:
url_call = 'https://data.import.io/extractor/{0}/json/latest?_apikey={1}'.format(extractors_row_dict['id'], auth_key)
r = requests.get(url_call)
with open(temporary_json_file_path, 'w') as outfile:
json.dump(r.content, outfile)
data = []
with open(temporary_json_file_path) as f:
for line in f:
data.append(json.loads(line))
Run Code Online (Sandbox Code Playgroud)
这样做的问题是,当我检查数据[0]时,所有的json文件内容都被转储到其中......
data[1] = IndexError: list index out of range
Run Code Online (Sandbox Code Playgroud)
这是一个例子data[0][:300]:
u'{"url":"https://www.example.com/de/shop?condition[0]=new&page=1&lc=DE&l=de","result":{"extractorData":{"url":"https://www.example.com/de/shop?condition[0]=new&page=1&lc=DE&l=de","resourceId":"23455234","data":[{"group":[{"Brand":[{"text":"Brand","href":"https://www.example.com'
Run Code Online (Sandbox Code Playgroud)
有没有人对此API的响应有经验?我从其他来源做的所有其他jsonline读取工作正常,除了这一个.
根据评论编辑:
print repr(open(temporary_json_file_path).read(300))
Run Code Online (Sandbox Code Playgroud)
给出这个:
'"{\\"url\\":\\"https://www.example.com/de/shop?condition[0]=new&page=1&lc=DE&l=de\\",\\"result\\":{\\"extractorData\\":{\\"url\\":\\"https://www.example.com/de/shop?condition[0]=new&page=1&lc=DE&l=de\\",\\"resourceId\\":\\"df8de15cede2e96fce5fe7e77180e848\\",\\"data\\":[{\\"group\\":[{\\"Brand\\":[{\\"text\\":\\"Bra'
Run Code Online (Sandbox Code Playgroud) 我试图从一个简单的 Remix 合同中获取记录在浏览器控制台上的详细信息。但是,当我尝试以下 html 时,我收到一条错误消息:
web3.eth.contract 不是函数
查看文档,我看到了变化:
var RemixContract = web3.eth.contract([
Run Code Online (Sandbox Code Playgroud)
为了这:
var RemixContract = new web3.eth.Contract([
Run Code Online (Sandbox Code Playgroud)
至少允许分配合同变量,但是我无法使用该RemixContract.at函数调用智能合同数据。我相信这与旧的 Web3 版本有冲突,但我无法弄清楚如何将数据带入浏览器控制台。
所需的输出是:能够在浏览器控制台上看到我的合同的详细信息。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Deploy a Remix Contract</title>
<link rel="stylesheet" type="text/css" href="main.css">
<!--The following line contains the source of web3 in case it is not on the directory-->
<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>
</head>
<body>
<div>
<h1>Deploy a Remix Contract</h1>
</div>
<script>
// Connect to the web3 provider
if …Run Code Online (Sandbox Code Playgroud) python ×5
import.io ×2
api ×1
docker ×1
drive ×1
gspread ×1
http ×1
json ×1
jsonlines ×1
postgresql ×1
pystan ×1
python-2.7 ×1
remix ×1
session ×1
sqlalchemy ×1