通过爬虫反查IP地址

加入你知道 对方的网络IP

71.112.190.213

抓取的链接: https://site.ip138.com/71.112.190.213/

python 复制代码
# !/usr/bin/env python
# -*-coding:utf-8 -*-

"""
# File       : two_spider_ip.py
# Time       :2024/1/30 9:34
# Author     :Jewel
# version    :python 3.9.8
# Description:
"""
import time

import pandas as pd
import requests
from icecream import ic
import re

def get_address(ip):
    ic(ip)
    url = f'https://site.ip138.com/{ip}/'

    data = {
        # 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
    }
    response = requests.get(url, headers=data)
    html_str = response.text
    address = re.findall('<h3>(.*?)</h3>', html_str)
    print(address)  # ['美国 犹他 盐湖城 Level3']
    return address[0]





if __name__ == '__main__':

    df_ips = pd.read_csv('./email_null.csv')

    df_all=df_ips.reset_index(drop=True)
    for ids, value in df_all.iterrows():
        ic(value)
        ip = value['user_ip'].split(',')[0]
        ips = get_address(ip)
        df_all.loc[ids, 'pi'] = ips
        time.sleep(1)

    df_all.to_csv('./two_ips.csv', index=False)


相关推荐
sugar椰子皮17 分钟前
【web补环境篇-0】document.all
爬虫
interception1 小时前
js逆向之京东原型链补环境h5st
javascript·爬虫·网络爬虫
Filotimo_1 小时前
桥接服务概念
网络协议·网络安全·信息与通信
镜中人★1 小时前
408计算机网络考纲知识点(更新中)
网络·网络协议·计算机网络
xflySnail2 小时前
nas服务域名高速访问-获取公网IP和端口
网络·tcp/ip·智能路由器
禾叙_3 小时前
【netty】Netty之TCP链接
网络·网络协议·tcp/ip
半路_出家ren3 小时前
17.python爬虫基础,基于正则表达式的爬虫,基于BeautifulSoup的爬虫
网络·爬虫·python·网络协议·正则表达式·网络爬虫·beautifulsoup
栗子叶3 小时前
SSE、长轮询与 WebSocket 连接资源对比及 Spring Boot 配置指南
spring boot·websocket·网络协议
徐子童3 小时前
网络协议---TCP协议
网络·网络协议·tcp/ip·面试题·1024程序员节
UrSpecial3 小时前
IP网络协议
服务器·网络·tcp/ip