What I need is to set header values defined outside def interceptor(request) function. How can I pass it?
def randomkeklul(main_arg):
return random.choice(['kek', 'lul']), random.choice(main_arg)
def interceptor(request):
request.headers['Accept-Encoding'] = value1
request.headers['Accept-Language'] = value2
def main():
main_arg = '12345'
value1, value2 = randomkeklul(main_arg)
driver.request_interceptor = interceptor
It doesn't help https://github.com/wkeeling/selenium-wire#example-add-a-request-header It works as driver.request_interceptor = interceptor but if I try to add arguments so it looks like
def randomkeklul(main_arg):
return random.choice(['kek', 'lul']), random.choice(main_arg)
def interceptor(request,arg1,arg2):
request.headers['Accept-Encoding'] = arg1
request.headers['Accept-Language'] = arg2
def main():
main_arg = '12345'
value1, value2 = randomkeklul(main_arg)
driver.request_interceptor = interceptor(arg1=value1, arg2=value2)
it raises error
TypeError: interceptor() missing 1 required positional argument: 'request'
I have the same issue. The only think that works fine for me is to get the parameters from some other function/file: