4 Commits

Author SHA1 Message Date
Galen Reich
6cc32ce7e4 Switch browser to Google Chrome from Chromium 2024-03-26 13:41:32 +00:00
Galen Reich
6d0f4ac372 Update path handling to be platform agnostic 2024-03-26 13:41:00 +00:00
Logan Williams
19ccd8f957 Change Webdriver manager import 2023-11-21 12:44:57 +01:00
msramalho
068f7ca9b9 deps quick fix 2023-11-16 17:11:15 +01:00
2 changed files with 11 additions and 10 deletions

View File

@@ -7,14 +7,10 @@ from datetime import datetime, timezone
from itertools import product
from statistics import pstdev
from string import Template
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 time import sleep
import requests
import pathlib
# gets instagram "locations" around a particular lat/lng using internal API
# (requires session cookie for authentication)
@@ -119,14 +115,19 @@ def encode_date(date_str: str):
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.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()

View File

@@ -3,7 +3,7 @@ _MAJOR = "1"
_MINOR = "3"
# On main and in a nightly release the patch should be one ahead of the last
# released build.
_PATCH = "0"
_PATCH = "1"
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
# https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = ""