我可以输入以下 url 以通过访问/请求以下端点来获取所有带有 #losangeles 标签的 IG 帖子:
https://www.instagram.com/explore/tags/losangeles/?__a=1
Run Code Online (Sandbox Code Playgroud)
在从这个 url 返回的 json 数据中,我可以看到 page_info 属性,其中有 has_next_page 属性,并且设置为 true。我的问题是如何修改上面的 url 以进入下一页,然后是下一页,直到我检查 has_next_page 并且它是假的。
尝试似乎很直观
https://www.instagram.com/explore/tags/losangeles/?__a=2
Run Code Online (Sandbox Code Playgroud)
和
https://www.instagram.com/explore/tags/losangeles/?__b=1
Run Code Online (Sandbox Code Playgroud)
但两者似乎都不起作用。我怀疑从原始 url 返回的数据中的 end_cursor 属性可能是我需要转到下一页的 url 的线索,但我不确定。有谁知道如何做到这一点?
我正在跟踪一个教程,可以在这里找到在ec2实例上设置无头硒刮刀的教程:
https://krbnite.github.io/Driving-Headless-Chrome-with-Selenium-on-AWS-EC2/
我正在使用的教程似乎假定使用Ubuntu发行版,而我正在使用的ec2实例是aws ami。由于这样的apt-get对我不可用,因此我使用yum安装东西。
安装过程的第一步如下:
wget -q -O - "https://dl-ssl.google.com/linux/linux_signing_key.pub" | sudo apt-key add -
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我得到以下是我的aws ami实例上的预期错误:
sudo: apt-key: command not found
Run Code Online (Sandbox Code Playgroud)
我不知道如果不使用apt,apt-get或apt-key而是使用yum,等效命令将是什么。我盲目尝试了以下方法,但它们没有起作用:
wget -q -O - "https://dl-ssl.google.com/linux/linux_signing_key.pub" | sudo yum add -
wget -q -O - "https://dl-ssl.google.com/linux/linux_signing_key.pub" | sudo yum-key add -
Run Code Online (Sandbox Code Playgroud)
谢谢
我有以下代码,其目的是遍历当前Apple地图视图上的所有注释并更新其位置坐标.
for existingMarker in self.mapView.annotations {
existingMarker.coordinate.latitude = 12.12121212
existingMarker.coordinate.longitude = 14.312121121
}
Run Code Online (Sandbox Code Playgroud)
可悲的是,这是不允许的.我被告知'坐标'是一个唯一的属性.所以这显然不是我想要更新MKAnnotation已经在mapView上绘制的注释的位置.那怎么办呢?具体来说,我想这样做并让地图"重绘"新坐标尽快.我确信这一定是可能的,因为它似乎是一个常见的用例.
具体来说,什么时候使用其中一个更好?我现在正在使用BatchGetItem,它似乎非常缓慢.
我的viacsv.py文件中有以下代码,旨在允许自定义捆绑包被摄取:
#
# Ingest stock csv files to create a zipline data bundle
import os
import numpy as np
import pandas as pd
import datetime
boDebug=True # Set True to get trace messages
from zipline.utils.cli import maybe_show_progress
def viacsv(symbols,start=None,end=None):
# strict this in memory so that we can reiterate over it.
# (Because it could be a generator and they live only once)
tuSymbols = tuple(symbols)
if boDebug:
print "entering viacsv. tuSymbols=",tuSymbols
# Define our custom ingest function
def ingest(environ, …Run Code Online (Sandbox Code Playgroud) 假设我在谷歌云存储 gs://example-bucket/testing_data 上的以下 URL 中存储了一张名为 sun.jpg 的图片
所以图片的完整网址是:
gs://example-bucket/testing_data/sunset.jpg
Run Code Online (Sandbox Code Playgroud)
如果我再做类似的事情:
image = cv2.imread('gs://example-bucket/testing_data/sunset.jpg')
Run Code Online (Sandbox Code Playgroud)
但是,虽然这不会崩溃或失败,但不会加载任何图像。我如何访问/提供正确的 URL 到 cv2.imread 来做到这一点?
google-cloud-storage google-cloud-platform google-cloud-datalab
假设我有一个像这样的 imgur 网址:https ://imgur.com/pCEoGjF
从网址我不知道这是图片还是gif。我知道我可以在文件末尾添加“.jpg”以获得图像的直接链接,但如果链接恰好是 gif,这也会显示 gif。我将如何以编程方式(使用 imgur API 或其他方式)检查 url https://imgur.com/pCEoGjF或https://imgur.com/pCEoGjF.jpg 上的项目是图像还是 gif?
编辑:我试过这个
print(requests.head(submission.url + ".jpg").headers['Content-Type'])
Run Code Online (Sandbox Code Playgroud)
但它抱怨以下错误:
KeyError: 'content-type'
Run Code Online (Sandbox Code Playgroud)
暗示内容类型不是标题中的键。我打印了标题并确认了这一点,因为它们如下:
{'Content-Length': '0', 'X-Served-By': 'cache-sjc3138-SJC', 'X-Cache': 'HIT', 'Accept-Ranges': 'bytes', 'X-Timer': 'S1498627080.598287,VS0,VE0', 'Server': 'cat factory 1.0', 'Retry-After': '0', 'Connection': 'close', 'X-Cache-Hits': '0', 'Location': 'https://i.imgur.com/APMnK9t.jpg', 'Cache-Control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'Date': 'Wed, 28 Jun 2017 05:17:59 GMT', 'X-Frame-Options': 'DENY'}
Run Code Online (Sandbox Code Playgroud)
我想我可以检查 content-length 是否不为 0 以查看它是否是 gif?想法?
我按照指南在这里设置我的 api:https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04
它工作得很好,我现在可以成功地对我的 api 进行查询。我的问题是,现在我想调整我的 Flask 应用程序/API 以执行稍微不同的操作并添加功能,但我正在 ping 的 API 似乎是旧的,尽管我已通过 ssh 更新了服务器上的 Flask .py 文件。我尝试完成教程中的所有步骤,希望能够刷新它访问的代码,但似乎没有任何效果。我尝试过的一些命令是:
sudo nginx -t
sudo service nginx restart
Run Code Online (Sandbox Code Playgroud)
我该如何执行此操作并 ping 更新的 Flask .py 文件?
根据我尝试过的建议:
restart myproject
Run Code Online (Sandbox Code Playgroud)
但这给出了以下错误:
restart: Rejected send message, 1 matched rules; type="method_call", sender=":1.8" (uid=1000 pid=2596 comm="restart thonapi ") interface="com.ubuntu.Upstart0_6.Job" member="Restart" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init ")
Run Code Online (Sandbox Code Playgroud) 我在代码中定义了以下 DAG:
from datetime import timedelta, datetime
import airflow
from airflow import DAG
from airflow.operators.docker_operator import DockerOperator
from airflow.contrib.operators.ecs_operator import ECSOperator
default_args = {
'owner': 'airflow',
'retries': 1,
'retry_delay': timedelta(minutes=5),
'start_date': datetime(2018, 9, 24, 10, 00, 00)
}
dag = DAG(
'data-push',
default_args=default_args,
schedule_interval='0 0 * * 1,4',
)
colors = ['blue', 'red', 'yellow']
for color in colors:
ECSOperator(dag=dag,
task_id='data-push-for-%s' % (color),
task_definition= 'generic-push-colors',
cluster= 'MY_ECS_CLUSTER_ARN',
launch_type= 'FARGATE',
overrides={
'containerOverrides': [
{
'name': 'push-colors-container',
'command': [color]
}
]
},
region_name='us-east-1', …Run Code Online (Sandbox Code Playgroud) python ×4
airflow ×1
amazon-ami ×1
amazon-ecs ×1
api ×1
apple-maps ×1
apt ×1
calendar ×1
cllocation ×1
flask ×1
gif ×1
imgur ×1
instagram ×1
ios ×1
mkannotation ×1
nginx ×1
performance ×1
swift ×1
ubuntu ×1
yum ×1
zipline ×1