Hello can you tell me how to use the tor browser via selenium so far I have only found this:
from tbselenium.tbdriver import TorBrowserDriver
with TorBrowserDriver('C:\Users\Brotb\Downloads\win (1)\vendor\tor-bundle') as driver:
driver.get('https://google.com')
and this doesnt work
can somebody help me?
Related
I'd like to open a Chrome instance on Python though selenium using a proxy to hide my real IP and stop getting blocked when I scrape certain websites.
I have been going thought several similar posts like this and this but with no success.
I am using the following code:
from selenium import webdriver
PROXY = "165.22.62.179:8118" # IP:PORT or HOST:PORT
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)
chrome = webdriver.Chrome(executable_path = path_to_chromedriver, options=chrome_options)
chrome.get(target_website)
The instance open correctly but when I run the command chrome.get(target_website) I get no answer:
If I open the instance without proxy it works fine. I am getting the proxies from this website. I want to create a function that takes as input a proxy IP and returns a running Chrome instance that uses that IP.
Can you please me help to fix my code? Thanks for your help!
I already know how to open chrome, but I do not know how to open a specific page from the URL. I'm using python 3.6
To open a webpage in your default browser:
import webbrowser
webbrowser.open("https://stackoverflow.com/questions/53796343")
To open a webpage in a new tab in Chrome:
import webbrowser
chrome_controller = webbrowser.get(using="chromium-browser")
chrome_controller.open_new_tab("https://stackoverflow.com/questions/53796343")
If this doesn't work for you, there are alternative values of the using parameter. Check the module's documentation.
Below code is creating an empty task_list.html file. It is not saving the full html content file , which is what i want . How to fix it?
from selenium import webdriver
import codecs
driver = webdriver.Firefox()
html = driver.page_source
driver.get("<our_internal_work_website>")
with open(r"C:\Users\task_list.html", "wb") as f:
f.write(html.encode('utf-8'))
Few points:
I am brand new to Python, just started few days back and troubleshooting issues as they come by searching on stackoverflow.
I am running this code on interactive shell on Powershell in Windows 10.
I manually enter the login credentials when opens . I have still not reached expertise to be able to put login details automatically.
I do not have html/css knowledge , so will google around in order to troubleshoot.
I want to use beautiful soup in order to parse the html , but it also requires login credentials and i do not know where to put the login credentials because it doesnt explicitly open the "Firefox" browser. Due to that , for now i am working with Selenium, because it can open the Firefox browser.
I'm using Selenium 3.5 for Python to test some behaviors of my web app using both local pages and online ones.
Until now, I just used Chrome as main browser to test it and everything works fine. Then, I decided to use Firefox 55.0.3 using geckodriver v0.19.0.
I have the following issues:
selenium opens the local pages such as file:///PATH/index.html but it doesn't close the browser even using the function quit();
I would use some browser option such as the incognito mode, but I was not able to find a list of all available options for Firefox.
This is a snippet of my code to use selenium with Firefox.
from selenium import webdriver
url = 'http://www.yahoo.com'
#url = 'file:///PATH/index.html'
browser = webdriver.Firefox()
browser.get(url)
browser.quit()
# borser.close() -> I also tried with the close()
I also read this question for the first issue but it doesn't work with the current version of the used framework.
About the second I can only find partial solution such as this one for the incognito mode but it doesn't work as expected.
Any ideas? Is it a kind of bug in geckodriver?
I am sure many of us are using Selenium to test applications with URL starting with https://....
I am facing this issue in my client network local and Jumpboxes, whenever I do a driver.get(“https://....”) to these URLs.
URLs starting with http://.... works fine.
I am using gecko 0.14, selenium 3.3.1 standalone server and Mozilla 50.1.0. Also checked with gecko 0.15.
Went through the suggestions over net and tried out the following workarounds :
• Creating new profile and setting capabilities and other properties. This helps manually , but through selenium the same issue persists.
• Adding Exception in Browser for new profile as well as default profile.
• Downloaded Mozilla 52.0 and tried the same.
None of them helped me out.
Questions :
Is this a proxy issue.
Can this be resolved.
Issue going on for a while. Please let us know if anything helped you out to resolve this.
Thanks,
Arpan
First you need to create a new FireFox profile say "myProfile".
ProfilesIni prof = new ProfilesIni()
FirefoxProfile ffProfile= prof.getProfile ("myProfile")
Now we need to set "setAcceptUntrustedCertificates" and "setAssumeUntrustedCertificateIssuer" properties in the FireFox profile.
ffProfile.setAcceptUntrustedCertificates(true)
ffProfile.setAssumeUntrustedCertificateIssuer(false)
WebDriver driver = new FirefoxDriver (ffProfile)
"setAcceptUntrustedCertificates" and "setAssumeUntrustedCertificateIssuer" are capabilities to handle the certificate errors in web browsers.