Python Forum
Fake UserAgent Issue NEED HELP !
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fake UserAgent Issue NEED HELP !
#1
This opens new fake useragent everytime but rondom useragent chooses alot of very old and not used user agents. How can I import from my useragent list as txt in here. I'm beginner level so I have very little knowladge sorry.

import time,sys,random,string,requests,hashlib,json,re
from pprint import pprint
import pymysql as MySQLdb
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

from fake_useragent import UserAgent
ua = UserAgent()
Reply
#2
adultsitem Wrote:I'm beginner level so I have very little knowladge sorry.
You should still try something an post that code,as reading a file has a lot of tutorial out there Wink

Let's say have a ua.txt file like this.
Output:
user-agent=Mozilla/5.0 1111 user-agent=Mozilla/5.0 2222 user-agent=Mozilla/5.0 3333
Read and make a list,then can eg choice a random from that list.
import random

with open('ua.txt') as f:
    ua = [i.strip() for i in f]

first = ua[0]
rand_ua = random.choice(ua)
print(first)
print(rand_ua)
Output:
user-agent=Mozilla/5.0 1111 user-agent=Mozilla/5.0 3333
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to find difference between fake driving license or real using python? pjaymn 2 2,543 Dec-20-2020, 08:41 PM
Last Post: jefsummers
  generate a fake lag using python? jhave_21 4 4,554 Nov-12-2017, 04:23 AM
Last Post: jhave_21

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020