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

posted @ 2020-11-27 15:17  就是无聊  阅读(635)  评论(0编辑  收藏  举报
帮找资源 代理IP 动态pptp 换IP软件 动态VPN 代理IP