Skip to content

Commit 1048830

Browse files
authored
Merge pull request #1 from hotessy/master
made changes
2 parents 43e82d5 + 29b9f3f commit 1048830

File tree

9 files changed

+224
-298
lines changed

9 files changed

+224
-298
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
.DS_Store
12
posts.txt
23
cursor.txt
3-
.ipynb_checkpoints
4+
.ipynb_checkpoints/
45
__pycache__/
56
try.ipynb
7+
.idea
8+
data/
9+
*.log

.ipynb_checkpoints/dateToId-checkpoint.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

.ipynb_checkpoints/scraper-checkpoint.py

Lines changed: 0 additions & 86 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Usage
2+
3+
```
4+
python scraper.py [-h] [--dir DIR] --max MAX_DATE --min MIN_DATE --location LOCATION
5+
[--restore-cursor] [--log-level LOG_LEVEL]
6+
```
7+
8+
### Example
9+
1. Standard: `python scraper.py --max "2020/07/15" --min "2020/06/15" --location "New-York-City"`
10+
2. Custom directory: `python scraper.py --dir "./data" --max "2020/07/15" --min "2020/06/15" --location "New-York-City
11+
" --restore-cursor`
12+
3. Log debug messages: `python scraper.py --max "2020/07/15" --min "2020/06/15" --location "New-York-City" -- log-level
13+
10`
14+
4. Restore from last saved post: `python scraper.py --max "2020/07/15" --min "2020/06/15" --location "New-York-City" --restore-cursor`

dateToId.py

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
1-
#Instagram Time ID converter
1+
# Instagram Time ID converter
22

33
import datetime
4-
print('hello')
54

6-
def get_location()->str:
7-
return input('Enter the URL of the location (for example: https://www.instagram.com/explore/locations/95099702/mgm-grand-las-vegas/)')
8-
def get_date()-> str:
9-
return input('Enter the date in this form: 1999/7/27... (leave no zeros in front of single digit months/days)')
10-
5+
6+
def get_location() -> str:
7+
return input(
8+
'Enter the URL of the location (for example: https://www.instagram.com/explore/locations/95099702/mgm-grand-las-vegas/)')
9+
10+
11+
def get_date() -> str:
12+
return input('Enter the date in this form: 1999/7/27... (leave no zeros in front of single digit months/days)')
13+
14+
1115
def date_str_2_dateobj(date: str) -> datetime.datetime:
12-
d_list = date.split("/")
13-
return datetime.datetime(int(d_list[0]), int(d_list[1]), int(d_list[2]), 23, 59, 59)
14-
15-
def date_2_unix(date_obj: datetime.date)-> int:
16-
unixdate = date_obj - datetime.datetime(1970,1,1)
17-
mstime = int(unixdate.total_seconds() * 1000.0)
18-
insta_epoch = mstime - 1314220021300
19-
return insta_epoch
20-
21-
def binary_decimal_convert(bindec: tuple)-> int:
22-
# print(bin(bindec[1]))
23-
if bindec[0]:
24-
return int(bin(bindec[1])[2:])
25-
else:
26-
return int(bindec[1], 2)
27-
28-
def binary_lengthen(binary: int)-> int:
29-
zeroes = 41 - len(str(binary))
30-
six_fourbit = ('0' * zeroes) + str(binary) + ('0' * 23)
31-
return six_fourbit
16+
d_list = date.split("/")
17+
return datetime.datetime(int(d_list[0]), int(d_list[1]), int(d_list[2]), 23, 59, 59)
3218

33-
def run(date):
34-
# location_url = get_location()
35-
unix_time = date_2_unix(date_str_2_dateobj(date))
36-
newbin = binary_decimal_convert((True, unix_time))
37-
longbin = binary_lengthen(newbin)
38-
final_num = binary_decimal_convert((False, longbin))
39-
return str(final_num)
4019

20+
def date_2_unix(date_obj: datetime.date) -> int:
21+
unixdate = date_obj - datetime.datetime(1970, 1, 1)
22+
mstime = int(unixdate.total_seconds() * 1000.0)
23+
insta_epoch = mstime - 1314220021300
24+
return insta_epoch
4125

42-
# print(run())
26+
27+
def binary_decimal_convert(bindec: tuple) -> int:
28+
# print(bin(bindec[1]))
29+
if bindec[0]:
30+
return int(bin(bindec[1])[2:])
31+
else:
32+
return int(bindec[1], 2)
33+
34+
35+
def binary_lengthen(binary: int) -> int:
36+
zeroes = 41 - len(str(binary))
37+
six_fourbit = ('0' * zeroes) + str(binary) + ('0' * 23)
38+
return six_fourbit
39+
40+
41+
def run(date):
42+
# location_url = get_location()
43+
unix_time = date_2_unix(date_str_2_dateobj(date))
44+
newbin = binary_decimal_convert((True, unix_time))
45+
longbin = binary_lengthen(newbin)
46+
final_num = binary_decimal_convert((False, longbin))
47+
return str(final_num)

metros.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"Minneapolis": "214063175",
3+
"New-York-City": "486560663",
4+
"Los-Angeles": "212999109",
5+
"Los-Angeles-Hollywood": "226233904",
6+
"Chicago": "204517928",
7+
"Chicago-Downtown": "244157761",
8+
"Houston": "212962809",
9+
"Phoenix": "211529586",
10+
"Philadelphia": "214228753",
11+
"San-Antonio": "212945639",
12+
"San-Diego": "212983635",
13+
"Dallas": "212900916",
14+
"San-Jose": "213070948",
15+
"Austin": "212964995",
16+
"Fort-Worth": "214001058",
17+
"Columbus, GA": "219362155",
18+
"Columbus, OH": "215824708",
19+
"Charlotte": "213141085",
20+
"San-Francisco": "44961364",
21+
"Seattle": "213941548",
22+
"Denver": "4599325",
23+
"Washington": "402206457",
24+
"Washington D.C.": "213480180",
25+
"Boston": "206698624",
26+
"Nashville-Downtown": "48918239",
27+
"Nashville": "213213692",
28+
"Oklahoma City": "213235913",
29+
"Oklahoma": "469882534",
30+
"Portland, OR": "107711604",
31+
"Portland, ME": "10099015",
32+
"Las-Vegas": "212901056",
33+
"Memphis": "215262999",
34+
"Louisville": "113226037",
35+
"Baltimore": "507294",
36+
"Milwaukee": "651007421",
37+
"Albuquerque": "214566258",
38+
"Tucson": "213215421",
39+
"Fresno": "213429027",
40+
"Sacramento": "212931804",
41+
"Atlanta-Downtown": "216249274",
42+
"Atlanta": "212947533",
43+
"Kansas-City": "213970592",
44+
"Colorado-Springs": "106270412737566",
45+
"Omaha": "214530463",
46+
"Raleigh": "213295703",
47+
"Miami": "212941492",
48+
"Long-Beach": "213193724",
49+
"Virginia": "375992293",
50+
"Oakland": "213051194",
51+
"Tulsa": "222331593",
52+
"Tampa": "213124046",
53+
"New-Orleans": "213424196"
54+
}

metros.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

readme.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)