这里的工作是从一个站点中抓取一个 API https://xxx.xxx.xxx/xxx/1.json,https://xxx.xxx.xxx/xxx/1417749.json并将其准确地写入 mongodb。为此,我有以下代码:
client = pymongo.MongoClient("mongodb://127.0.0.1:27017")
db = client["thread1"]
com = db["threadcol"]
start_time = time.time()
write_log = open("logging.log", "a")
min = 1
max = 1417749
for n in range(min, max):
response = requests.get("https:/xx.xxx.xxx/{}.json".format(str(n)))
if response.status_code == 200:
parsed = json.loads(response.text)
inserted = com.insert_one(parsed)
write_log.write(str(n) + "\t" + str(inserted) + "\n")
print(str(n) + "\t" + str(inserted) + "\n")
write_log.close()
Run Code Online (Sandbox Code Playgroud)
但是完成这项任务需要花费大量时间。这里的问题是我怎样才能加快这个过程。
Helm 3 imagePullSecrets: [] secrete 给出错误。
错误:无法从发布清单构建 Kubernetes 对象:错误验证“”:错误验证数据:ValidationError(Deployment.spec.template.spec.imagePullSecrets[0]):io.k8s.api.core.v1.LocalObjectReference 的无效类型:得到“字符串”,预期“地图”
我正在尝试将字符串的多行写入 Python3 中的文本文件,但它只写入单行。
例如
假设打印我的字符串会在控制台中返回该字符串;
>> print(mylongstring)
https://www.link1.com
https://www.link2.com
https://www.link3.com
https://www.link4.com
https://www.link5.com
https://www.link6.com
Run Code Online (Sandbox Code Playgroud)
我将其写入文本文件
f = open("temporary.txt","w+")
f.write(mylongstring)
Run Code Online (Sandbox Code Playgroud)
我的文本文件中读取的所有内容都是第一个链接(link1.com)
有什么帮助吗?如果您愿意,我可以详细说明,毕竟这是我的第一篇文章。
我在不同的服务器(许多机器)中有网络应用程序的日志。如何在安装了 Elastic search 和 Kibana 的系统中收集这些日志。当我搜索时,我只找到了显示设置的教程,其中logs、logstash、beats和都在一起。elasticsearchkibana
我有许多指向入口控制器 IP 的域。我想阻止所有域/站点的/特定路径。有没有办法做到这一点。我可以用于nginx.ingress.kubernetes.io/configuration-snippet: | 每个网站。但正在寻找同时处理所有站点/域/入口资源的方法。
使用的控制器: https: //kubernetes.github.io/ingress-nginx/
如果存在文本属性,我想显示一个归属链接;如果为空或未定义,则不显示任何内容。
if (relatedurl)
{section {
content {
attribution-link {
label {
template ("Related content: ")
}
url ("#{value(this.relatedurl)}")
}
}
}
Run Code Online (Sandbox Code Playgroud)
这显示为空,而没有 if 的相同代码正确显示归因链接。如何制定测试?
我有这样的数据
Datas =
[{'playerid': 'ABCD2612', 'Series': 'U11', 'Points': [810.0, 360.0, 360.0, 251.25]}
{'playerid': 'CDEF2077', 'Series': 'U13', 'Points': [810.0, 540.0, 270.0, 270.0]}
{'playerid': 'HIJK0140', 'Series': 'U15', 'Points': [810.0, 675.0, 540.0, 540.0]}
{'playerid': 'LMNO0315', 'Series': 'U17', 'Points': [945.0, 810.0, 675.0, 540.0]}
{'playerid': 'ABCD2612', 'Series': 'U11', 'Points': [810.0, 360.0, 360.0, 251.25]}
{'playerid': 'CDEF2077', 'Series': 'U13', 'Points': [810.0, 540.0, 270.0, 270.0]}
{'playerid': 'HIJK0140', 'Series': 'U15', 'Points': [810.0, 675.0, 540.0, 540.0]}
{'playerid': 'LMNO0315', 'Series': 'U17', 'Points': [945.0, 810.0, 675.0, 540.0]}]
Run Code Online (Sandbox Code Playgroud)
我需要根据玩家 ID 和系列从数据中删除重复项
输出看起来像这样
output …Run Code Online (Sandbox Code Playgroud) python ×3
kubernetes ×2
python-3.x ×2
bixby ×1
dictionary ×1
helm-tls ×1
list ×1
mongodb ×1
nginx ×1
pymongo ×1
web-scraping ×1