initial commit of project

This commit is contained in:
2021-04-11 19:51:12 +02:00
commit a21a8186d9
110 changed files with 16326178 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
"""
Read user agents from list (local file) and select one for the request.
"""
import random
def user_agent_list(user_agent_list_path):
"""Read user agents from list (local file). """
with open(user_agent_list_path, "r") as f:
agent_list = f.readlines()
return agent_list
def select_user_agent(agent_list):
"""Select random user agent from pre-loaded list of agents. """
n_agents = len(agent_list)
agent = {}
agent["user-agent"] = agent_list[random.randint(0, n_agents-1)].replace("\n", "").replace("\"", "")
return agent