Advertisement

Python脚本用于验证码识别与登录实现

阅读量:

Python爬虫:验证码识别登录

验证码图片获取流程

复制代码
    import requests
    from lxml import etree
    url='https://so.gushiwen.org/user/login.aspx?from='
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36'
    }
    img_code_text=requests.get(url=url,headers=headers).text
    tree=etree.HTML(img_code_text)
    img_src_url='https://so.gushiwen.org'+tree.xpath('//*[@id="imgCode"]/@src')[0]
    img_data=requests.get(url=img_src_url,headers=headers).content
    with open('./code.jpg','wb')as fp:
    fp

全部评论 (0)

还没有任何评论哟~