mirror of
https://github.com/bellingcat/instagram-location-search.git
synced 2026-06-10 11:38:28 +03:00
Compare commits
3 Commits
v1.3.1
...
fix-cookie
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cc32ce7e4 | ||
|
|
6d0f4ac372 | ||
|
|
19ccd8f957 |
@@ -10,7 +10,7 @@ from string import Template
|
||||
from time import sleep
|
||||
|
||||
import requests
|
||||
|
||||
import pathlib
|
||||
|
||||
# gets instagram "locations" around a particular lat/lng using internal API
|
||||
# (requires session cookie for authentication)
|
||||
@@ -118,15 +118,16 @@ def get_insta_cookies():
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service as ChromiumService
|
||||
from webdriver_manager.chrome import ChromeDriverManager
|
||||
from webdriver_manager.core.utils import ChromeType
|
||||
from webdriver_manager.core.os_manager import ChromeType
|
||||
"""
|
||||
Attempts to run selenium, provide user with the login form and extract cookies from page to be used in program.
|
||||
Returns cookies formatted as name=value;name=value;...
|
||||
"""
|
||||
path = str(pathlib.Path.home() / ".instagram_location_searcher" / "data")
|
||||
options = webdriver.ChromeOptions()
|
||||
options.add_argument(r"--user-data-dir=~/.instagram_location_searcher/data")
|
||||
options.add_argument(r'--profile-directory=~/.instagram_location_searcher/profile')
|
||||
driver = webdriver.Chrome(options=options, service=ChromiumService(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()))
|
||||
options.add_argument(f"user-data-dir={path}")
|
||||
options.add_argument(f"profile-directory=profile")
|
||||
driver = webdriver.Chrome(options=options, service=ChromiumService(ChromeDriverManager(chrome_type=ChromeType.GOOGLE).install()))
|
||||
driver.get("https://www.instagram.com/")
|
||||
# Check that there is cookie with name sessionid (mean we logged in)
|
||||
cookies = driver.get_cookies()
|
||||
@@ -261,4 +262,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user