python爬虫登录第一资源网

# -*- coding:utf-8 -*- 
# -Author-= JamesBen
# Email: [email protected] 

import  requests
from tqdm import tqdm
#cookie保持
session = requests.Session()
auth_url = "http://www.dyboy.cn/content/templates/vip_dux/user/auth.php"
requests = requests.get(auth_url)

pbar = tqdm(range(1000))
for  i in pbar:
    #下载验证码
    code_url = "http://www.dyboy.cn/include/lib/checkcode.php?1581048674174"
    cap_response = session.get(code_url )

    #第三步,保存验证码
    desktop_path = "F:\\python测试\\第一资源网验证码\\"    # 新创建的txt文件的存放路径
    name = "第一资源网登录验证码"+str(i)+".jpg"
    full_path = desktop_path + name

    f = open(full_path,"wb")
    f.write(cap_response.content) #二进制数据
    f.close()


    pbar.set_description("已下载".format(i))



发布了153 篇原创文章 · 获赞 248 · 访问量 33万+

猜你喜欢

转载自blog.csdn.net/qq_45172832/article/details/105332691
今日推荐