Python selenium: Firefox auto download everything - python

I am trying to download a csv file from a website and no matter how many MIME's I try for both saving and opening, the dialog box still appears. Is there a way to cover all MIME's at once or anything that might pop up?
Right now I'm using:
fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/html")
fp.set_preference("browser.helperApps.neverAsk.openFile","text/html")
And other variations including a ton more MIME's. How can I auto download regardless of the MIME?

I solved my question with this:
fp.set_preference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream")
fp.set_preference("browser.helperApps.neverAsk.openFile","application/octet-stream")
I had multiple preference statements, and I think that is what the problem was. Now I only have this one active and don't have any problems. Hope this can help someone else.

Related

my jupyter notebook is pasting unncessary program lines inbetween

when I try to write any code jupyter notebook automatically paste any irrelevant / sometimes relevant program between the program, but I want to stop this shit, because it is irritating me. suggestions are different things. but this issue has arrived in my notebook for the past few days.you can see in this link exactly what happening in this link
how can I get rid of it? please help me out. The error lines are in green color whereas normal program looks like thisSee this line in grey color is suggested by notebook
I am just confused. I don't know how it started. I didn't get any solution on it anywhere
looks like https://discourse.jupyter.org/t/jupyter-notebooks-annoying-grey-text-auto-show/16886/5, This is most likely a browser issue, what browser are you using? any extentions that could cause this? maybe try switching browsers?

Why doesn't highlighted text show what data type the highlighted text is?

I'm using pyton with VSC and ran into a problem while watching a tutorial; when highlighting a number in brackets, the data type doesn't show up, while it does in the tutorial. IE: when higlighting 4.5 in
print(4.5), it should say 4.5: float in a popup, but that doesn't happen. Can anybody help me?
Visual Studio Code does not have automatic intellisense, you need to download a language specific extention to use it.
Steps to download:
open the extentions menu located on the left toolbar (ctrl-shift-x).
search for python.
click install on the top result.
(optional) restart VSC, I don't know if it is necessary, but better safe then sorry.
I hope this fixes your problem :) .
Edit: I just checked, and after installing the extention will say something along the lines of 'reload to enable extention', if it does not, it doesn't need it. Otherwise, just click the text that says that.

Question about using selenium+pyautogui to upload file

Recently I need to upload my dataset on a website, the first part works fine on selenium.
However, after I click the 'upload' button, a windows file broswer pops-up.
And after searching online, I finally make it work by using pyautogui, code:
pyautogui.write('K:\Github\###\data\global\Global_PM_corT.csv') # enter file with path
pyautogui.press('enter') # click ok
My question is, I want to use above process on Github Action.
So, i changed:
'K:\Github\###\data\global\Global_PM_corT.csv'
to:
'./data/global/Global_PM_corT.csv'
and it's not working.
I think there is some error when using relative path with pyautogui.
So, i was wondering if someone could help me achieve this? Thanks in advance:)
P.S.
its working right now.
I first read the dataset by
pd.read_csv('path')
then write it on github action
to_csv('C:\\Global_PM_corT.csv')
then I can use absolute path with pyautogui:)
However, I still want to know if a better way to achieve this
Please try this:
'./data/global/Global_PM_corT.csv'

How to close a tab in Spyder for Mac OS?

I had this little problem that made me crazy for a while, until I ran into the solution by chance, so even if it'is a trivial issue I want to share it.
Just click on the left side of the name of the file, on its tab, in the tabs bar. It's like a hidden button. Check the pictureHope it will be useful to somebody

windows warning starting chrome with Selenium Python

I've just started coding in python with selenium, but here is my problem :
When I start Chrome with selenium,I ve a warning message from windows (my computer is in french, but it ask if I want to reset my setting). And I would like to close that tab, to make my program continue on another tab.
But it seems impossible to close it. I tried :
the Alert class of selenium, did nothing, the code just go through it
Moving mouse to the cross, or to "dismiss" (with selenium obviously) just the same
Switching tab, and close it (with selenium's control command), it doesnt change anything
Open Chrome with my usual settings (still from selenium), with that mode i can t open my url anymore, but i dont have the warning message too ...
I would be so grateful if someone had an idea, or have already had that problem. In fact, i would just want to dismiss it, to make my program run, without having to close the window at the start.
Apologize me for my english, that's not my native language, but I swear that I do my best :/
Thank you very much to all, feel free to ask me more informations :)
AR
Edit: I can't forbid you to put a -1, but try to explain me in which way it deserves it, then, I'll try to correct me, or to give more details.
Here the solution, even if I would prefer a patch from Selenium, because to my mind, that is a trouble comming from Selenium/python + windows + chrome combination : I ve created a new profile on chrome, add the X.add_argument("user-data-dir=...) It doesn't open my profile (I've maybe done a mistake in the path to the folder) BUT the warning message disappears with that line, all I wanted, then thank you very much Bill Bell ;)

Categories