zoukankan      html  css  js  c++  java
  • python+fastapi自建HTTP爬虫IP池接口

    使用的库

    • bs4
    • requests
    • pymongo
    • fastapi
    • uvicorn

    爬取ip

    网络上搜索一下有很多提供HTTP代理的网站,直接使用BeautifulSoup将IP爬下来。

    html =requests.get(url).text
    bs =BeautifulSoup(html,'html.perser')
    #findAll()
    #select()
    
    

    验证ip

    res = requests.get(url,headers=headers,proxies=proxies)
    #判断res.status_code是否等于200
    #db.insert_one()
    

    如果验证成功写入数据库。

    接口

    使用fastapi

    @app.get('/api')
    def api():
    	data = 查询数据库随机返回一条
    	return data
    

    效果展示

    https://998ip.com
    https://www.ipzdc.com

    演示地址:找IP

  • 相关阅读:
    053364
    053363
    oracle导出批量表N行记录
    053362
    053361
    053360
    053359
    053358
    053357
    053356
  • 原文地址:https://www.cnblogs.com/aosky/p/14048149.html
Copyright © 2011-2022 走看看