'Allow facebook cookies to track me through multiple sessions in selenium
I'm working on scraping data using selenium, for an academic research which will test how certain user behaviors across facebook and the web will affect the ads they see.
For this, I need to have a kinds of fake user which will first interact with facebook, then visit some sites with facebook cookies, allowing facebook to continue tracking its behavior, and then go back to facebook.
I haven't done much web development, and it seems I'm confused about how exactly to keep and load cookies for this scenario.
I've been trying to save and load cooking using the following code snippets:
# saving
pickle.dump(driver.get_cookies(), cookiesfile)
# loading
cookies = pickle.load(cookiesfile)
for cookie in cookies:
driver.add_cookie(cookie)
On facebook , this will either create an error message popup telling me to reload, or redirect me to the login page. On other sites, even ones that explicitly state they have facebook trackers, this will cause an InvalidCookieDomainException.
What am I doing wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
