In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
#! / usr/bin/env python#_*_coding:utf-8 _ * _ _ author__ = 'gaogd'import datetime,threadingimport sys, os, urllib2, jsonreload (sys) sys.setdefaultencoding (' utf8') ips = {} # ip as the key of the dictionary, valueiplist = [] # iterate through the ip in the log, and the same ip will also be recorded in the list Insert database fh = open (". / ip.txt", "r"). Readlines () # I put the log and code in a directory for line in fh: ip = line.split (") [0] if 6
< len(ip) use intest;Database changedmysql>Create table ipinfo (id int auto_increment primary key,ipaddress varchar, countip int); Query OK, 0 rows affected (0.22 sec) mysql > create table whereip (id int primary key auto_increment,country varchar, area varchar, region varchar, city varchar, ip varchar, time datetime); Query OK, 0 rows affected (0.20 sec) mysql > mysql > desc ipinfo +-+ | Field | Type | Null | Key | Default | Extra | + -+ | id | int (11) | NO | PRI | NULL | auto_increment | | ipaddress | varchar | YES | | NULL | | countip | int (11) | YES | | NULL | | +- -+-+ 3 rows in set (0.00 sec) mysql > desc whereip +-+ | Field | Type | Null | Key | Default | Extra | +- -+ | id | int (11) | NO | PRI | NULL | auto_increment | | country | varchar | YES | | NULL | | area | varchar | YES | | NULL | | region | varchar | YES | NULL | | | | city | varchar | YES | | NULL | ip | varchar | YES | | NULL | | time | datetime | YES | | NULL | | +-| -+-+ 7 rows in set (0.00 sec) mysql >
After analyzing the log, view the contents of the database:
Mysql > select * from whereip limit 10 +-- + | id | country | area | region | city | ip | time | + -+ | 1 | United States | 66.249.65.133 | 2016-09-01 10:53:01 | | 2 | USA | 23.251.63.45 | 2016-09-01 10:53:01 | 3 | United States | 23.251.63.45 | 2016-09-01 10:53:01 | 4 | China | South China | Guangdong Province | Guangzhou | 119.130.71.153 | 2016-09-01 10:53:01 | | 5 | United States | 66.249.65.183 | 2016-09-01 10:53:01 | | 6 | United States | 66.249.65.180 | 2016-09-01 10:53:01 | 7 | United States | | | 66.249.65.142 | 2016-09-01 10:53:01 | | 8 | United States | 107.151.226.203 | 2016-09-01 10:53:01 | | 9 | United States | 107.151.226.203 | 2016-09-01 10:53:01 | 10 | United States | | | 66.249.65.134 | 2016-09-01 10:53:01 | +-- +-- -- + 10 rows in set (0.00 sec) mysql >
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.