通过爬虫反查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)


相关推荐
zhengfei6113 小时前
高级网络安全爬虫/蜘蛛
爬虫
开开心心就好4 小时前
键盘映射工具改键位,绿色版设置后重启生效
网络·windows·tcp/ip·pdf·计算机外设·电脑·excel
恬淡如雪4 小时前
Excel接口测试自动化实战
爬虫·python·excel
不知名。。。。。。。。4 小时前
传输层————TCP/UDP
网络协议·tcp/ip·udp
m0_663234014 小时前
Libvio.link爬虫技术全解析
爬虫
REDcker4 小时前
RFC1918私有IP地址空间详解
网络协议·tcp/ip·php
深蓝电商API5 小时前
httpx库异步爬虫实战对比aiohttp
爬虫·httpx
Flamingˢ5 小时前
FPGA中的存储器模型:从IP核到ROM的深度解析与应用实例
网络协议·tcp/ip·fpga开发
吠品5 小时前
IP证书-SSL证书申请
网络·网络协议·tcp/ip
四月_h5 小时前
vue2项目集成websocket
网络·websocket·网络协议