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


相关推荐
网络小江16 小时前
上网第三十九课:TCP 的可靠性——滑动窗口、重传与拥塞控制
网络协议
91刘仁德18 小时前
HTTP协议详解:从URL到HTTP服务器的完整实战
服务器·网络·笔记·网络协议·http
可乐鸡翅yeah_20 小时前
hls.js 手动自定义 http 请求 loader,修改请求头实战
开发语言·前端·javascript·网络协议·http·ecmascript·m3u8在线
pt10431 天前
CML网络仿真入门-2:使用CML模拟网络实验环境
运维·网络协议
wuyk5551 天前
Python 网络爬虫入门到实战 第 04 章:请求头、UA 伪装、超时、异常处理、基础反爬绕过
开发语言·爬虫·python
熊文豪1 天前
KingbaseES 数据加密全解:从 SSL 到全密态
网络·网络协议·ssl
91刘仁德1 天前
Linux网络编程从入门到实战:UDP/TCP协议与socket编程全解析
linux·网络·笔记·tcp/ip·udp
网络小江1 天前
上网第三十八课:TCP 三次握手与四次挥手——连接到底是怎么“谈“成的
网络协议
AIgorithmGEEK1 天前
[Linux]HTTP 应用层协议全解(下篇)
linux·网络·网络协议·http·cookie·无连接·无状态