Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7709067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:46:16+00:00 2026-06-01T00:46:16+00:00

I’ve been trying to find a proper solution to my problem for several days

  • 0

I’ve been trying to find a proper solution to my problem for several days now looking everywhere. Hopefully some of you guys can direct me to the right direction.

I am trying to implement a system with proxy list. Where system is picking up proxy from list, trying to connect using it and if it failed to connect, modify the line of the proxy in proxy.txt with ” = 1″ means Timed Out one time.

When system will stumble on this proxy again next time and it will fail again, it should modify ” = 1″ to ” = 2″ etc. Converting string to int, changing values and then converting back to string is not difficult to do.

My problem here is what I can’t find the way how to put cursor to specific proxy and then replace ” = Number” value. I can find proxy by using .seek(), but taking into account that every proxy has different length of characters .seek(proxy + 20) simply won’t work…

For example, proxy.txt has:

192.168.0.1:8000 = 2
192.168.0.10:80 = 1
192.168.0.100:3128 = 2
192.168.0.4:8080
192.168.0.5:7822 = 2
192.168.0.6:8005

Even if I can find the proxy I need by scanning every line and then fire .seek(address of the proxy), how can I move then to “=” character?

I know if might be much easier just to copy everything from text file to pickle file and then modify everything there by using dictionaries etc.
But the idea is that I can open text file at any time and see what proxies are failing.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:46:17+00:00Added an answer on June 1, 2026 at 12:46 am

    Depending on the file size, and whether you will be changing the length of an entry in the file, it is probably easier to just read the entire file into memory. However, if you still want to read/write in place:

    Say I want to modify the entry 192.168.0.10:80 = 1 so it reads 192.168.0.10:80 = 2.

    searchValue = "192.168.0.10:80"
    newNumber = 2
    
    f = open("datafile.txt", "r+b")
    
    for line in file:
        if line.split()[0] == searchValue:
            position = f.tell() - len(line) #the tell() method gives the current position in the file
            f.seek(position)
            f.write("%s = %d" % (searchValue, newNumber))
            break
    
    f.close()
    

    NOTE: This will only work if you are not modifying the length of any of the entries (including adding whitespace) if the length of the entries changes at all (i.e. if you are changing 192.168.0.10:80\n to 192.168.0.10:80 = 1\n) then you will overwrite a portion of the next line in the file. If this is the case, you are better off reading the file into memory and then modifying it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.