1、获取hostname

相同代码

不同宿主机

日志名 互异 且 可识别宿主机

分布式爬虫

https://docs.python.org/3.6/library/socket.html#socket.SOCK_RAW

socket.gethostbyname(socket.gethostname())

import socket

>>> socket.gethostname()
'hadoop1'
>>> socket.gethostbyname('qq.com')
'14.17.32.211'
>>> socket.gethostbyname(socket.gethostname())
'192.168.2.51'
>>>

python 获取代码宿主机名 ip的更多相关文章

  1. (转)linux获取/查看本机出口ip

    获取/查看本机出口ip  curl http://members.3322.org/dyndns/getip 1 curl ifconfig.me 2 #或者 3 curl http://member ...

  2. python获取到本机的公网IP

    5行代码获取到本机的公网IP from urllib.request import urlopen import re text = str(urlopen("http://txt.go.s ...

  3. python获取linux本机IP

    #!/usr/bin/env python #encoding: utf-8 #description: get local ip address import os import socket, f ...

  4. python 获取当前调用函数名等log信息

    import sys funcName = sys._getframe().f_back.f_code.co_name #获取调用函数名 lineNumber = sys._getframe().f_ ...

  5. python获取代码行号

    获取行号: def get_file(): print("文件名 :",__file__,sys._getframe().f_lineno) print("函数名: &q ...

  6. 【趣】Python获取变量的变量名

    两种不完美的方式: 用locals,globals 用locals获取变量列表,再遍历比较对象. def namestr(obj): ns = globals() return [name for n ...

  7. 在有多个网卡,配置了多个IP的情况下,python 获取本地网卡的主IP

    如图所示有多个网卡 本地网卡配置了多个IP class Public_IPOp: @staticmethod def GetLocalIP(): rt = [False] # 根节点 reg_root ...

  8. 【LINUX】——如何配置宿主机和虚拟机IP在同一网段

    宿主机:win7  10.8.2.50 255.255.255.0 虚拟机:redhat 如果使用 NAT 的网络连接方式,虚拟机的 IP 会被分配为 192.168.*.* 网段,从虚拟机 ping ...

  9. Vmware Centos7 配置静态 ip 和 使宿主机和虚拟机互相 ping 通

    NAT 方式1. 配置静态 ipVmware 安装 Centos7 可以参考 https://blog.csdn.net/guo_ridgepole/article/details/78973763 ...

随机推荐

  1. 5.12-leepcode 作业详解

    leepcode 作业详解 1.给定一个整数数组,判断是否存在重复元素.如果任何值在数组中出现至少两次,函数返回 true.如果数组中每个元素都不相同,则返回 false. 正确解答 class So ...

  2. 使用scrapy爬取suning

    # -*- coding: utf-8 -*- import scrapy from copy import deepcopy class SuSpider(scrapy.Spider): name ...

  3. LeetCode(51) N-Queens

    题目 The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two quee ...

  4. 洛谷 1067 NOIP2009 普及组 多项式输出

    [题解] 一道简单的模拟题.需要判一些特殊情况:第一项的正号不用输出,x的一次项不用输出指数,系数为0的项不用输出等等,稍微细心一下就好. #include<cstdio> #includ ...

  5. luogu3168 [CQOI2015]任务查询系统

    树状数组不用动脑子真爽啊 #include <algorithm> #include <iostream> #include <cstdio> using name ...

  6. js正则替换十六进制

    var re=/\x62/;//没有0,也没有分号。alert(re.test("blue"));  //output "true" 需要使用< 如需显示 ...

  7. 大数据学习——安装zooleeper

    1 alt+p,上传zookeeper-3.4.5.tar.gz 2 解压安装包 ,安装在apps目录下 tar -zxvf zookeeper-3.4.5.tar.gz -C apps 3 删除zo ...

  8. Python+selenium(Autolt实现上传)

    AutoIt是一个使用类似BASIC脚本语言的免费软件,被设计用来进行Windows GUI的自动化测试.它利用模拟键盘按键,鼠标移动和窗口/控件的组合来实现自动化任务. 此次小编介绍的是利用Auto ...

  9. sql语句中嵌套2层循环

    declare @year intdeclare @month intset @year=2008 while(@year<=2011)beginset @month=1while(@month ...

  10. Android View加载圆形图片且同时绘制圆形图片的外部边缘边线及边框:LayerDrawable实现

     Android View加载圆形图片且同时绘制圆形图片的外部边缘边线及边框:LayerDrawable实现 LayerDrawable实现的结果和附录文章1,2,3中的layer-list一致. ...