forked from InstaPy/instagram-profilecrawl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrawl_profile_without_posts.py
More file actions
executable file
·47 lines (38 loc) · 1.39 KB
/
crawl_profile_without_posts.py
File metadata and controls
executable file
·47 lines (38 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3.5
"""Goes through all usernames and collects their information"""
import json
import datetime
from util.settings import Settings
from util.datasaver import Datasaver
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from util.cli_helper import get_all_user_names
from util.extractor import extract_information
chrome_options = Options()
chrome_options.add_argument('--dns-prefetch-disable')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--lang=en-US')
chrome_options.add_argument('--headless')
chrome_options.add_experimental_option('prefs', {'intl.accept_languages': 'en-US'})
browser = webdriver.Chrome('./assets/chromedriver', chrome_options=chrome_options)
# makes sure slower connections work as well
print ("Waiting 10 sec")
browser.implicitly_wait(5)
Settings.limit_amount = 1
Settings.scrap_posts_infos = False
try:
usernames = get_all_user_names()
for username in usernames:
print('Extracting information from ' + username)
information = []
user_commented_list = []
try:
information, user_commented_list = extract_information(browser, username, Settings.limit_amount)
except:
print("Error with user " + username)
Datasaver.save_profile_json(username,information)
except KeyboardInterrupt:
print('Aborted...')
finally:
browser.delete_all_cookies()
browser.close()