#-*- coding:utf-8 -*-

import threading
import requests
import time
import urllib3
import json

urllib3.disable_warnings()

def getCrawl(url):
     session = requests.Session()
     session.trust_env = False
     session.verify = False
     receive = session.get(url)
     text = receive.text
     # text = text.encode('utf-8')
     mtext = json.dumps({"k": text})
     # print(json.loads(mtext)["k"])
     text = json.loads(mtext)["k"];
     time.sleep(1)
     print(text)
     get_data = json.dumps(text, indent=4)
     print(get_data)
target = "http://somesite.co.kr/uri1/uri2"
thread = threading.Thread(target=getCrawl, args=(target,))
thread.daemon = False
thread.start()

#print('Out of thread')

'Python' 카테고리의 다른 글

Getting snmp informations with python script  (0) 2020.04.22
USING THREAD IN PYTHON  (0) 2020.04.07
CRAWLING WITH PYTHON  (0) 2020.04.07
TRY TO CONNECT VIA SMB OR CIFS  (0) 2020.04.07
TRY TO CONNECT VIA MYSQL  (0) 2020.04.07
import sys
from pysnmp.hlapi import *
import csv


def walk(host, oid):
    for (errorIndication, errorStatus, errorIndex, varBinds) in nextCmd(SnmpEngine(), CommunityData('public'),
                                                                        UdpTransportTarget((host, 161), timeout=1,
                                                                                           retries=5), ContextData(),
                                                                        ObjectType(ObjectIdentity(oid)),
                                                                        lexicographicMode=True, lookupNames=True):
        if errorIndication:
            print(errorIndication, file=sys.stderr)
            break
        elif errorStatus:
            print('%s at %s' % (errorStatus.prettyPrint(), errorIndex and varBind[int(errorIndex) - 1][0] or '?'),
                  file=sys.stderr)
            break
        else:
            for varBind in varBinds:
                print(varBind)


def checkserver(ip):
    walk(ip, '1.3.6')


with open('snmplist.csv', newline='', encoding='utf-8') as csvfile:
    reader = csv.reader(csvfile, quoting=csv.QUOTE_ALL)
    for row in reader:
        try:
            print('IP : ' + row[0])
            checkserver(row[0])
        except:
            pass

'Python' 카테고리의 다른 글

Crawling Json type with Python thread  (0) 2020.04.26
USING THREAD IN PYTHON  (0) 2020.04.07
CRAWLING WITH PYTHON  (0) 2020.04.07
TRY TO CONNECT VIA SMB OR CIFS  (0) 2020.04.07
TRY TO CONNECT VIA MYSQL  (0) 2020.04.07
import requests
from bs4 import BeautifulSoup

session = requests.Session()
session.trust_env = False
session.verify = False

receive = session.get(url='http://www.google.com')
html = receive.text

bsObj = BeautifulSoup(html, 'html.parser')

for div in bsObj.find_all('div'):
     print(div.get('id'))

'Python' 카테고리의 다른 글

Getting snmp informations with python script  (0) 2020.04.22
USING THREAD IN PYTHON  (0) 2020.04.07
TRY TO CONNECT VIA SMB OR CIFS  (0) 2020.04.07
TRY TO CONNECT VIA MYSQL  (0) 2020.04.07
TRY TO TEST FOR DEFAULT ACCOUNT VIA TELNET  (0) 2020.04.07

+ Recent posts