user-agent

Scrapy - Correct way to change User Agent in Request

旧时模样 提交于 2021-02-16 14:13:22
问题 I have created a custom Middleware in Scrapy by overriding the RetryMiddleware which changes both Proxy and User-Agent before retrying. It looks like this class CustomRetryMiddleware(RetryMiddleware): def _retry(self, request, reason, spider): retries = request.meta.get('retry_times', 0) + 1 if retries <= self.max_retry_times: Proxy_UA_Middleware.switch_proxy() Proxy_UA_Middleware.switch_ua() logger.debug("Retrying %(request)s (failed %(retries)d times): %(reason)s", {'request': request,

How do I change the user agent in my WebView using Swift 4.2?

为君一笑 提交于 2021-02-16 09:37:27
问题 I'm struggling with changing the user agent on my project using the latest Xcode version with swift 4.2 . I want to pretend that I'm a Mac visiting a specific website. Please edit this code and post it in the comments Here's my code so far. class ViewController: UIViewController { @IBOutlet weak var webview: WKWebView! override func viewDidLoad() { super.viewDidLoad() let userAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36

How do I change the user agent in my WebView using Swift 4.2?

旧巷老猫 提交于 2021-02-16 09:36:46
问题 I'm struggling with changing the user agent on my project using the latest Xcode version with swift 4.2 . I want to pretend that I'm a Mac visiting a specific website. Please edit this code and post it in the comments Here's my code so far. class ViewController: UIViewController { @IBOutlet weak var webview: WKWebView! override func viewDidLoad() { super.viewDidLoad() let userAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36

UrlFetchApp.fetch() error, doesn't seem to be using headers

自作多情 提交于 2021-02-10 05:39:39
问题 Trying to grab data from a website using Google Apps Script to put it directly into a spreadsheet. The fetch does not seem to be working, where the Python requests equivalent works just fine. Python code: page = requests.get("someurl?as_data_structure", headers={'user-agent':'testagent'}) GAS code: var page = UrlFetchApp.fetch("someurl?as_data_structure", headers={'user-agent':'testagent'}); The only required header is the user-agent, and the error I am getting from the GAS code is what I

How can I reliably detect the browser without using window.navigator?

走远了吗. 提交于 2021-02-06 15:26:22
问题 I know there are a thousand questions on Stack Overflow about detecting the browser with JavaScript. My question is how can you detect the browser without window.navigator (which includes navigator.userAgent )? First, to clarify, I don't need to know the rendering engine, this isn't for adaptive layout, and don't panic: I'm already doing feature detection. If why I'm asking about detecting the browser is important, please comment and I'll be happy to splice in the explanation, but it will

How can I reliably detect the browser without using window.navigator?

半城伤御伤魂 提交于 2021-02-06 15:23:05
问题 I know there are a thousand questions on Stack Overflow about detecting the browser with JavaScript. My question is how can you detect the browser without window.navigator (which includes navigator.userAgent )? First, to clarify, I don't need to know the rendering engine, this isn't for adaptive layout, and don't panic: I'm already doing feature detection. If why I'm asking about detecting the browser is important, please comment and I'll be happy to splice in the explanation, but it will

Chrome's autofill hiding text input's background image

青春壹個敷衍的年華 提交于 2021-01-26 11:01:20
问题 After successfuly disabling the autofill's yellowish background-color, I stumbled upon another feature. Each of my input elements have a background image, and every time I focus on a text input, the browser suggests values I used before in a drop down list. After I pick a value, the autofill covers my entire background and hides the image. Here's my html and css (elaborated in JSfiddle): <section class="formContainer"> <img class="sesameLogo" src="~/Content/Images/Site/sesamelogo.png" />

AWS CloudFront - forward User-Agent but don't cache against it

拥有回忆 提交于 2021-01-20 19:31:37
问题 I want my origin to be able to see the User-Agent header .e.g: Gecko/20100101 Firefox/62.0 not Amazon CloudFront . In the Behaviors tab I can whitelist User-Agent header, so it's passed to the origin correctly, however now CloudFront caches content per User-Agent , meaning that user visiting the CloudFront endpoint from different browsers forces CloudFront to go to the origin. Is there any way to configure CloudFront to pass some headers to the origin, but not necessarily cache against them?

How to change user agent for Firefox webdriver in Python?

☆樱花仙子☆ 提交于 2020-12-06 16:12:45
问题 I'm building a search bot and i want it to change from Desktop to Mobile I tried to use profile.set_preferences but for some reason it wont change. It doesn't give compiling time error but it wont change the user agent. I also tried setting the desired capabilities but that didn't work either. if count == 0: browser = webdriver.Firefox(executable_path="geckodriver.exe") else: profile = webdriver.FirefoxProfile() profile.set_preference("general.useragent.override", "Mozilla/5.0 (Android 4.4;

How to change user agent for Firefox webdriver in Python?

浪尽此生 提交于 2020-12-06 15:56:36
问题 I'm building a search bot and i want it to change from Desktop to Mobile I tried to use profile.set_preferences but for some reason it wont change. It doesn't give compiling time error but it wont change the user agent. I also tried setting the desired capabilities but that didn't work either. if count == 0: browser = webdriver.Firefox(executable_path="geckodriver.exe") else: profile = webdriver.FirefoxProfile() profile.set_preference("general.useragent.override", "Mozilla/5.0 (Android 4.4;