'Is there a module or any other option that makes me not need to manually update my User Agent with every browser update in Python?
To work with User-Agent in request calls, I need to manually search and add in headers, like this:
import requests
import json
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36"
}
url = f'www.testforstackoverflow.com'
response = requests.get(url, headers=headers).json()
My question is if there is any way, for example, instead of having to manually get the User-Agent, to be able to import a module or anything else that would do this job, for example:
import user_agent
headers = {
"User-Agent": user_agent.data
}
I need to keep the User-Agent always updated, but as it will be running automatically, I would like not to have to manually analyze if there is a need to update.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
