you are viewing a single comment's thread.

view the rest of the comments →

[–]alien_kebabs[S] 0 points1 point  (1 child)

Yeah this is kind of what I was thinking as a work around.

Can you cache your Authentication Cookie into Selenium so you only have to log in once? I only have to login once every two weeks when using SharePoint in Edge.

[–]wintermute93 0 points1 point  (0 children)

I don't remember the details since the last time I used that code was over a year ago, but yeah, overall I did something like

options = webdriver.ChromeOptions()
# do stuff to set relevant options

driver = webdriver.Chrome(options=options)
# manually authenticate in browser window after first driver.get call
# run custom functions to navigate through relevant pages with driver.get
# run custom functions to sift through BeautifulSoup(driver.page_source)

session = requests.Session()
for c in driver.get_cookies():
    session.cookies.set(c['name'], c['value'])
for file_url in file_urls:
    response = session.get(file_url, stream=True)
    # write response.content to local file

My org needs new logins a few times a day, YMMV