Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect Data in a specific period (Since - Until) #121

Open
pvita opened this issue May 16, 2018 · 8 comments

Comments

@pvita
Copy link

commented May 16, 2018

Hi there,
is it possible to collect pictures (and metadata) only from a specific period?
For example all the pictures of the last year with a specific hashtag.

P.s. is it possible to collect just metadata (+comments; geotags etc) without downloading all the pictures?

Best
P

@Thammus

This comment has been minimized.

Copy link
Member

commented May 24, 2018

Hi,
you can play around with dropwhile and takewhile from itertools like in the following snippet:

from datetime import datetime
from itertools import dropwhile, takewhile

import instaloader

L = instaloader.Instaloader()

posts = L.get_hashtag_posts('milfgarden')
# or
# posts = instaloader.Profile.from_username(L.context, PROFILE).get_posts()

SINCE = datetime(2015, 5, 1)
UNTIL = datetime(2015, 3, 1)

for post in takewhile(lambda p: p.date > UNTIL, dropwhile(lambda p: p.date > SINCE, posts)):
    print(post.date)
    L.download_post(post, '#milfgarden')
@Thammus Thammus added the question label May 24, 2018
aandergr added a commit that referenced this issue Jun 4, 2018
Presents code examples that use the instaloader module for more advanced tasks
than what is possible with the Instaloader command line interface.

Presents #46, #56, #110, #113, #120, #121.
@aandergr aandergr added this to the Version 4.1 milestone Jun 14, 2018
@aandergr aandergr modified the milestones: Version 4.1, Version 4.2 Aug 31, 2018
@aandergr aandergr self-assigned this Sep 24, 2018
@stagenam3

This comment has been minimized.

Copy link

commented Oct 24, 2018

Hi! I tried out that feature (copy pasted the code, changed the hashtag and dates, and ran the script) and I get nothing, i.e. I do not get any error message and the script seems to have ran but I also do not get any results.

@aandergr aandergr removed this from the Version 4.2 milestone Dec 21, 2018
@Khoa-N

This comment has been minimized.

Copy link

commented Jan 4, 2019

I believe that the takewhile and the drop while lambda functions are swapped as when you call get_posts() with a profile the posts appear in the order of most recent to oldest.

@aandergr aandergr removed their assignment Feb 20, 2019
@suecys

This comment has been minimized.

Copy link

commented Apr 24, 2019

Hi, I have the same error as stagenam3, I get nothing when I change the dates and the hashtag. If I change the hashtag only, still nothing. What can I do to get results?

@oktayekici

This comment has been minimized.

Copy link

commented May 9, 2019

Same problem here. It does nothing after you run the code like the code has finished conducting.

@rohimari

This comment has been minimized.

Copy link

commented May 11, 2019

I get a problem, 429 Too Many Requests, how I can resolve it?

@rohimari

This comment has been minimized.

Copy link

commented May 11, 2019

Hi,
you can play around with dropwhile and takewhile from itertools like in the following snippet:

from datetime import datetime
from itertools import dropwhile, takewhile

import instaloader

L = instaloader.Instaloader()

posts = L.get_hashtag_posts('milfgarden')
# or
# posts = instaloader.Profile.from_username(L.context, PROFILE).get_posts()

SINCE = datetime(2015, 5, 1)
UNTIL = datetime(2015, 3, 1)

for post in takewhile(lambda p: p.date > UNTIL, dropwhile(lambda p: p.date > SINCE, posts)):
    print(post.date)
    L.download_post(post, '#milfgarden')

I can get a result from that code, but when I changed a hashtag and date, I get an error, 429 Too Many Requests.

@Alexhazl

This comment has been minimized.

Copy link

commented May 18, 2019

I have the same problem, I do not get the requests specified in the code and when the process finishes, appears a KeyError: 'query_hash'

What is happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.