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


相关推荐
让学习成为一种生活方式2 小时前
植物中验证蛋白相互作用的Pull-down和Co-IP技术--文献精读181
网络·网络协议·tcp/ip
普普通通的南瓜2 小时前
IP证书在关键信息基础设施安全防护中的实践与挑战
网络·数据库·网络协议·tcp/ip·安全·ssl
YFLICKERH5 小时前
【加密协议】SSL/TLS 协议工作流程
网络协议·ssl/tls
小白学大数据6 小时前
构建混合爬虫:何时使用Requests,何时切换至Selenium处理请求头?
爬虫·python·selenium·测试工具
4***72137 小时前
网络爬虫学习:借助DeepSeek完善爬虫软件,实现模拟鼠标右键点击,将链接另存为本地文件
爬虫·学习·计算机外设
t***31658 小时前
爬虫学习案例3
爬虫·python·学习
观望过往11 小时前
WebSocket 技术全解析:原理、应用与实现
网络·websocket·网络协议
阿珊和她的猫1 天前
HTTP 状态码 304:未修改(Not Modified)的深度解析
网络协议·http·状态模式
x***J3481 天前
Python多线程爬虫
开发语言·爬虫·python
m***D2861 天前
Python网络爬虫实战案例
开发语言·爬虫·python