Chrome python uses different than Chrome on desktop? - python

When I check the settings on Chrome on my desktop it is set to Allow all cookies. But when I run python, the Chrome that loads is set to Block third-party cookies in incognito.
This is a problem with one website that gives me the error message "You must have cookies enabled..."
Is the Chrome that python loads different than the one on my desktop? If so where is it located and how do I change the default setting?
If I change the setting on the python Chrome to Allow all cookies, the next time it loads it is back to the setting of Block third-party cookies in incognito.
I went into Regedit and set Chrome IncognitoModeAvailability to 0. This made the desktop Chrome to be set to Allow all cookies but that didn't change the python Chrome.
Or can I add an argument to set Chrome to Allow all cookies. I have found many examples of allowing incognito (chrome_options.add_argument("--incognito")) but none for allow all cookies.

Related

1. How to open Chrome as default browser from Python-based AI code? Right now it opens Internet explorer by default

while coding a Python-based AI when we are to access the internet through it. The Default web browser opens is Internet Explorer. How to get chrome as default?
I don't know the specifics of how your AI framework opens a browser nor the operating system you are using. I am using windows 10 and have installed Chrome in the default location.
Changing your default browser using the operating system, may work:
Open Default apps
Under Web browser, select the browser currently listed, and then select Google Chrome
Or you can use this method - it works even if chrome isn't your default browser:
import webbrowser
url = 'https://www.python.org'
path = 'C:/Program Files/Google/Chrome/Application/chrome.exe'
webbrowser.register('mybrowser', None, webbrowser.BackgroundBrowser(path))
webbrowser.get('mybrowser').open(url)
You can fetch the location of the chrome executable from the registry with the key:
HKML\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe
Or find it using the shell command:
dir /s /b \chrome.exe
See also:
How to change the default browser used by jupyter in windows
How to change the default browser used by jupyter in Linux
Change your default browser in Windows 10

need Adblockplus filter systemwide via /etc/hosts

I'm scraping some websites to get at content they have using selenium in python. I can run headless firefox via geckodriver with marionette capability set to True with adblockplus extension enabled and it works well. However recent versions of firefox (as of March 2021) don't support performance logging - which is a must for my purpose. So I've had to switch to using chromedriver and Chromium. Logging works great but chromium when being run in headless mode has no support for browser extensions and throws errors.
So I figure I keep using chromedriver with Chromium but not having adblockplus or any other adblocking is really hurting my runtime and there are some overlays that wouldn't be there otherwise.
How can I find and extract the filter list of my adblockplus browser extension so I can apply the same filtering by using the domain names in there and my /etc/hosts file i.e. sending all those 'bad' domains to 0.0.0.0
If you open the settings and click on the advanced. you will see the filters. Each filter points to an url where there are stored.
1.The easy list i previous linked: https://easylist-downloads.adblockplus.org/easylist.txt
2. The ABP filters https://easylist-downloads.adblockplus.org/abp-filters-anti-cv.txt

Why local chrome-urls like: chrome://downloads or chrome://apps doesn't work in headless mode?

I am trying to visit chrome local urls. But it's not working. Does headless chrome support local urls?
I was looking for exactly this just today.
Found this:
Most chrome internal pages are not implemented in headless mode. This is a limitation of headless Chrome itself, and is not related to ChromeDriver. If you need a particular internal page available in headless Chrome, please file a feature request at https://crbug.com/.
:(
source

How do you run Chrome while selenium headless script is executing on mac?

I have a python selenium script that uses chromedriver in headless mode to test links on a website. I'm running this script on MacOS High Sierra.
If I have Chrome open prior to running the script, I can continue to use the browser normally. Headless mode appears to isolate me from the testing. However, if Chrome is closed first, I cannot launch the browser while the selenium script is running.
Looking at Activity monitor in the first scenario, it appears to me that chromedriver creates a new process for Chrome to run. So I (perhaps incorrectly) assumed I should be able to launch the browser manually while the script is running.
What am I missing?
How do I launch Chrome while selenium is running on Mac?
Ah-HA!
This post I stumbled upon made it possible to open Chrome while selenium is running (although I don't understand why it works one way but not the other).
For most applications, launching with open -naF "App Name" or open -nF
/path/to/application.app should be sufficient (see Safari, Forklift,
Office apps, etc.).
-n opens a new instance
-a tells open to look in the list of registered apps (no need to specify the full path, but can go wrong if you have multiple versions
of an app. I sometimes see issues on my system with differentiating
between macOS apps and apps installed by Parallels OSes… I prefer to
specify the path directly.)
-F opens a fresh instance (ignores an app save state left over from previous instances)

Django let me log in in Firefox but not in chrome

I recently started playing with Django.
When I try to log in into the admin panel, it succeeds in Firefox but doesn't in Google Chrome.
This is the error i get :
Forbidden (CSRF cookie not set.): /admin/login/
My cookies are enabled in Chrome for every website. Is there a specific reason why it would work in Firefox but not in Chrome?
Thanks!
I had similar problem and the solution for me was to set Django setting
SESSION_COOKIE_SECURE = False
I know this is the default setting but I've been using production config with this set to True. So in my dev settings I changed it to False and was able to log in to admin panel in Chrome.
On Feb 2020 Chrome implemented a change that enforces that Secure cookies are only accessible via HTTPS protocol. So if you're developing locally and only using HTTP that is a killer. Firefox and Edge are yet to enforce Secure flag |(based on taday's versions)
Are you not developing using the c9 platform?
https://c9.io/
I reset my chrome setting and it worked fine.
In Chrome, click on the 3 dots on the far right and goto settings.
On settings page, scroll all the way down or click on the bottom left "Reset Settings" button and reset settings.

Categories

Resources