user-agent

fake_useragent module not connecting properly – IndexError: list index out of range

fake_useragent module not connecting properly – IndexError: list index out of range Question: I tried to use fake_useragent module with this block from fake_useragent import UserAgent ua = UserAgent() print(ua.random) But when the execution reached this line ua = UserAgent(), it throws this error Traceback (most recent call last): File "/home/hadi/Desktop/excel/gatewayform.py", line 191, in <module> …

Total answers: 2

Change user agent using selenium wire in Chrome

Change user agent using selenium wire in Chrome Question: I am attempting to change my user agent and print the changed user agent to the terminal to check whether it has been successfully changed however I am having no luck. I am using selenium wire and attempting to change it so i can login to …

Total answers: 3

How to change firefox profile preference after defining webdriver using Selenium and Python

How to change firefox profile preference after defining webdriver using Selenium and Python Question: How to change profile preference after defining driver? profile = webdriver.FirefoxProfile() driver = webdriver.Firefox(firefox_profile=profile) After some code need to set useragent profile.set_preference("general.useragent.override", ua) How to set it without defining new driver? Asked By: Tomain || Source Answers: I believe it’s not …

Total answers: 3

Trying to fake and rotating user agents

Trying to fake and rotating user agents Question: I am trying to fake user agents as well as rotate them in Python. I found a tutorial online about how to do this with Scrapy using scrapy-useragents package. I scrape the webpage, https://www.whatsmyua.info/, in order to check my user agent to see if it is different …

Total answers: 4

Way to change Google Chrome user agent in Selenium?

Way to change Google Chrome user agent in Selenium? Question: I’m trying to figure out a way whereby whenever I open up Chrome via Selenium (in Python) in this particular script, the Chrome page automatically opens up with another user agent selected – in this case, Microsoft Edge Mobile (but I will be accessing it …

Total answers: 2

Change user-agent for Selenium web-driver

Change user-agent for Selenium web-driver Question: I have the following code in Python: from selenium.webdriver import Firefox from contextlib import closing with closing(Firefox()) as browser: browser.get(url) I would like to print the user-agent HTTP header and possibly change it. Is it possible? Asked By: xralf || Source Answers: There is no way in Selenium to …

Total answers: 5

Changing User Agent in Python 3 for urrlib.request.urlopen

Changing User Agent in Python 3 for urrlib.request.urlopen Question: I want to open a url using urllib.request.urlopen(‘someurl’): with urllib.request.urlopen(‘someurl’) as url: b = url.read() I keep getting the following error: urllib.error.HTTPError: HTTP Error 403: Forbidden I understand the error to be due to the site not letting python access it, to stop bots wasting their …

Total answers: 4

Scrapy Python Set up User Agent

Scrapy Python Set up User Agent Question: I tried to override the user-agent of my crawlspider by adding an extra line to the project configuration file. Here is the code: [settings] default = myproject.settings USER_AGENT = “Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36” [deploy] #url = http://localhost:6800/ project = myproject But …

Total answers: 2

Detect mobile browser (not just iPhone) in python view

Detect mobile browser (not just iPhone) in python view Question: I have a web application written in Django that has one specific page I’d like to implement a mobile version of the template (and slightly different logic) for. I’d like to be able to implement it ala this sudo code: def(myView) do some stuff if …

Total answers: 3