Skip to content

Commit

Permalink
variable end date time
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseRZapata committed May 8, 2021
1 parent 2dcb10d commit 157e0de
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/pycoornet/crowdtangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, api_key):
self.api_key = api_key

def get_shares(self, urls, url_column='url', date_column='date', platforms=('facebook', 'instagram'),
nmax=500, sleep_time=20, clean_urls=False, save_ctapi_output=False, id_column=None, remove_days=None):
nmax=1000, sleep_time=20, clean_urls=False, save_ctapi_output=False, id_column=None, remove_days=None):
""" Get the URLs shares from CrowdTangle from a list of URLs with publish datetime
Args:
Expand Down Expand Up @@ -86,7 +86,12 @@ def get_shares(self, urls, url_column='url', date_column='date', platforms=('fac
# set date limits, endDate: one week after date_published
startDate = urls.iloc[i, :].loc['date']
#startDate = startDate.replace(microsecond=0)
endDate = startDate + pd.Timedelta('7 day')
if remove_days:
days = f"{remove_days} day"
endDate = startDate + pd.Timedelta(days)
else:
endDate = 'now'

url = urls.iloc[i, :].loc['url']
try:
# pycrowdtangle get links
Expand Down Expand Up @@ -152,8 +157,7 @@ def get_shares(self, urls, url_column='url', date_column='date', platforms=('fac
if id_column:
df_full["id_column"] = urls.iloc[i, :].loc[id_column]


# remove shares performed more than one week from first share
# remove shares performed more than x days from first share
if remove_days:
# ex: '7 day'
days = f"{remove_days} day"
Expand Down

0 comments on commit 157e0de

Please sign in to comment.