Skip to content

Commit

Permalink
Merge pull request #1 from hotessy/master
Browse files Browse the repository at this point in the history
made changes
  • Loading branch information
asmitks authored Aug 9, 2020
2 parents 43e82d5 + 29b9f3f commit 1048830
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 298 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.DS_Store
posts.txt
cursor.txt
.ipynb_checkpoints
.ipynb_checkpoints/
__pycache__/
try.ipynb
.idea
data/
*.log
42 changes: 0 additions & 42 deletions .ipynb_checkpoints/dateToId-checkpoint.py

This file was deleted.

86 changes: 0 additions & 86 deletions .ipynb_checkpoints/scraper-checkpoint.py

This file was deleted.

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Usage

```
python scraper.py [-h] [--dir DIR] --max MAX_DATE --min MIN_DATE --location LOCATION
[--restore-cursor] [--log-level LOG_LEVEL]
```

### Example
1. Standard: `python scraper.py --max "2020/07/15" --min "2020/06/15" --location "New-York-City"`
2. Custom directory: `python scraper.py --dir "./data" --max "2020/07/15" --min "2020/06/15" --location "New-York-City
" --restore-cursor`
3. Log debug messages: `python scraper.py --max "2020/07/15" --min "2020/06/15" --location "New-York-City" -- log-level
10`
4. Restore from last saved post: `python scraper.py --max "2020/07/15" --min "2020/06/15" --location "New-York-City" --restore-cursor`
75 changes: 40 additions & 35 deletions dateToId.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
#Instagram Time ID converter
# Instagram Time ID converter

import datetime
print('hello')

def get_location()->str:
return input('Enter the URL of the location (for example: https://www.instagram.com/explore/locations/95099702/mgm-grand-las-vegas/)')
def get_date()-> str:
return input('Enter the date in this form: 1999/7/27... (leave no zeros in front of single digit months/days)')


def get_location() -> str:
return input(
'Enter the URL of the location (for example: https://www.instagram.com/explore/locations/95099702/mgm-grand-las-vegas/)')


def get_date() -> str:
return input('Enter the date in this form: 1999/7/27... (leave no zeros in front of single digit months/days)')


def date_str_2_dateobj(date: str) -> datetime.datetime:
d_list = date.split("/")
return datetime.datetime(int(d_list[0]), int(d_list[1]), int(d_list[2]), 23, 59, 59)

def date_2_unix(date_obj: datetime.date)-> int:
unixdate = date_obj - datetime.datetime(1970,1,1)
mstime = int(unixdate.total_seconds() * 1000.0)
insta_epoch = mstime - 1314220021300
return insta_epoch

def binary_decimal_convert(bindec: tuple)-> int:
# print(bin(bindec[1]))
if bindec[0]:
return int(bin(bindec[1])[2:])
else:
return int(bindec[1], 2)

def binary_lengthen(binary: int)-> int:
zeroes = 41 - len(str(binary))
six_fourbit = ('0' * zeroes) + str(binary) + ('0' * 23)
return six_fourbit
d_list = date.split("/")
return datetime.datetime(int(d_list[0]), int(d_list[1]), int(d_list[2]), 23, 59, 59)

def run(date):
# location_url = get_location()
unix_time = date_2_unix(date_str_2_dateobj(date))
newbin = binary_decimal_convert((True, unix_time))
longbin = binary_lengthen(newbin)
final_num = binary_decimal_convert((False, longbin))
return str(final_num)

def date_2_unix(date_obj: datetime.date) -> int:
unixdate = date_obj - datetime.datetime(1970, 1, 1)
mstime = int(unixdate.total_seconds() * 1000.0)
insta_epoch = mstime - 1314220021300
return insta_epoch

# print(run())

def binary_decimal_convert(bindec: tuple) -> int:
# print(bin(bindec[1]))
if bindec[0]:
return int(bin(bindec[1])[2:])
else:
return int(bindec[1], 2)


def binary_lengthen(binary: int) -> int:
zeroes = 41 - len(str(binary))
six_fourbit = ('0' * zeroes) + str(binary) + ('0' * 23)
return six_fourbit


def run(date):
# location_url = get_location()
unix_time = date_2_unix(date_str_2_dateobj(date))
newbin = binary_decimal_convert((True, unix_time))
longbin = binary_lengthen(newbin)
final_num = binary_decimal_convert((False, longbin))
return str(final_num)
54 changes: 54 additions & 0 deletions metros.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"Minneapolis": "214063175",
"New-York-City": "486560663",
"Los-Angeles": "212999109",
"Los-Angeles-Hollywood": "226233904",
"Chicago": "204517928",
"Chicago-Downtown": "244157761",
"Houston": "212962809",
"Phoenix": "211529586",
"Philadelphia": "214228753",
"San-Antonio": "212945639",
"San-Diego": "212983635",
"Dallas": "212900916",
"San-Jose": "213070948",
"Austin": "212964995",
"Fort-Worth": "214001058",
"Columbus, GA": "219362155",
"Columbus, OH": "215824708",
"Charlotte": "213141085",
"San-Francisco": "44961364",
"Seattle": "213941548",
"Denver": "4599325",
"Washington": "402206457",
"Washington D.C.": "213480180",
"Boston": "206698624",
"Nashville-Downtown": "48918239",
"Nashville": "213213692",
"Oklahoma City": "213235913",
"Oklahoma": "469882534",
"Portland, OR": "107711604",
"Portland, ME": "10099015",
"Las-Vegas": "212901056",
"Memphis": "215262999",
"Louisville": "113226037",
"Baltimore": "507294",
"Milwaukee": "651007421",
"Albuquerque": "214566258",
"Tucson": "213215421",
"Fresno": "213429027",
"Sacramento": "212931804",
"Atlanta-Downtown": "216249274",
"Atlanta": "212947533",
"Kansas-City": "213970592",
"Colorado-Springs": "106270412737566",
"Omaha": "214530463",
"Raleigh": "213295703",
"Miami": "212941492",
"Long-Beach": "213193724",
"Virginia": "375992293",
"Oakland": "213051194",
"Tulsa": "222331593",
"Tampa": "213124046",
"New-Orleans": "213424196"
}
46 changes: 0 additions & 46 deletions metros.py

This file was deleted.

5 changes: 0 additions & 5 deletions readme.md

This file was deleted.

Loading

0 comments on commit 1048830

Please sign in to comment.