Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saving session changes #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion inscrawler/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import traceback
from builtins import open
from time import sleep
import pickle

from tqdm import tqdm

Expand Down Expand Up @@ -67,7 +68,14 @@ def __init__(self, has_screen=False):
super(InsCrawler, self).__init__()
self.browser = Browser(has_screen)
self.page_height = 0
self.login()
if os.path.exists("QuoraCookies.pkl"):
url = "%s/accounts/login/" % (InsCrawler.URL)
self.browser.get(url)

for cookie in pickle.load(open("QuoraCookies.pkl", "rb")):
self.browser.driver.add_cookie(cookie)
else:
self.login()

def _dismiss_login_prompt(self):
ele_login = self.browser.find_one(".Ls00D .Szr5J")
Expand All @@ -85,6 +93,7 @@ def login(self):

login_btn = browser.find_one(".L3NKy")
login_btn.click()
pickle.dump(self.browser.driver.get_cookies() , open("QuoraCookies.pkl","wb"))

@retry()
def check_login():
Expand Down