Giter VIP home page Giter VIP logo

python-'s Introduction

python-

my project about Reptile

  1. add get_IP.py that Auto crawl proxy IP address Store the crawled IP address in the TXT text. When the set proxy IP fails, it will automatically switch the available IP in the text to continue crawling data;

IP change function

def proxies_switch(url):
    print("正在进行ip的切换...")
    global ip_num
    stutas = False
    while stutas ==False: #找到合适的ip——post地址
        print("正在验证第%s个ip地址"%(ip_num))
        with open('./IP.txt','r',encoding="utf-8") as text:
            rows = text.readlines()
        print(len(rows))
        if ip_num*5+4 > len(rows):
            print("没有合适的IP地址")
            break
        ip = rows[ip_num*5][:-1]
        post = rows[ip_num*5+1][:-1]
        type = rows[ip_num * 5 + 3][:-1].lower()
        ip_post = ip+":"+post
        response = requests.get(url, headers=header1 if random.random()>0.5 else header2, proxies={type:ip_post})
        stutas = response.ok
        ip_num = ip_num+1
    proxies['https'] = ip_post
    print("第%d个ip地址测试成功"%(ip_num))
    time.sleep(0.5) #切换成功之后sleep一秒 防止新的ip_post被封

python-'s People

Contributors

oyjgithub avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.