Skip to content

Instantly share code, notes, and snippets.

@tienntr
Last active September 26, 2024 07:09
Show Gist options
  • Save tienntr/e7269bbea1d726a2097b5622085136a0 to your computer and use it in GitHub Desktop.
Save tienntr/e7269bbea1d726a2097b5622085136a0 to your computer and use it in GitHub Desktop.
User agent changing

Change user-agent with privoxy

/etc/privoxy/user.action

{+hide-user-agent{Mozilla/5.0 (Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0} \
 +add-header{User-Agent: Mozilla/5.0 (Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0} \
}
/

Pip

This section is obsoleted with the introduction of +add_header action above.

Privoxy doesn't work with Python 3.10 pip because the latter doesn't set UA. Temporay hack:

  • Create venv
  • Edit <venv>/lib/python3.10/site-packages/pip/_vendor/requests/adapters.py, change function proxy_header in class HTTPAdapter to add a 'User-Agent' header to the return dict.
  • Use pip from the venv.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment