加入你知道 对方的网络IP
71.112.190.213
抓取的链接: https://site.ip138.com/71.112.190.213/
# !/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)
文章评论