코드 백업

5065 단어
간단 한 파충 류 는 이 안에 간단 한 압축 및 암호 화 프로그램 이 쓰 여 있 기 때문에 실행 이 끝나 면 접미사 이름 이 없 는 파일 두 개 와 json 파일 하 나 를 볼 수 있 습 니 다.암호 화의 목적 은 원래 아 리 클 라 우 드 서버 에 넣 기 위해 서 였 으 나 클 라 우 드 방패 에 감지 되 지 않 았 다.물론 관련 코드 (코드 에 표 시 됨) 를 삭제 하고 그림 으로 저장 할 수도 있 습 니 다.
모든 함 수 를 보류 하고 다른 부분 을 삭제 합 니 다. 안녕 히 계 세 요!
# -*- coding: UTF-8 -*-
import threading
import requests
import re
import time
from bs4 import BeautifulSoup
import os
import urllib
import zipfile
import shutil
import json


def downIMG(url,path):
	opener = urllib.request.build_opener()
	opener.addheaders = [('User-agent', 'Opera/9.80 (Android 2.3.4; Linux; Opera Mobi/build-1107180945; U; en-GB) Presto/2.8.149 Version/11.10')]
	urllib.request.install_opener(opener) 
	urllib.request.urlretrieve(url,path)
	return;

def getall(page,num,site,filepath):
	mainsite=site+'/thread0806.php?fid=16&search=&page='+str(page)
	mhtml = requests.get(mainsite)
	mhtml.encoding = 'gbk'
	part_siteURL = re.findall(r"

.+?

",mhtml.text,re.S) urls = [] links=[]; titles=[]; effect=[]; if(page==1): start=9 else: start=0 for n in range(start,len(part_siteURL)-1): link=re.findall(r"htm_data.+?\.html",part_siteURL[n],re.S) if not len(link)==0: link=site+'/'+link[0] # https://www.baidu.com/ effect.append(n) links.append(link) title=re.findall(r"

()*(.+?)<./>

",part_siteURL[n],re.S) #print(title[0][1]) title=title[0][1] titles.append(title) website=links[num-1] html = requests.get(website) html.encoding = 'gbk' res = requests.get(website) res.encoding = 'gbk' soup = BeautifulSoup(res.text, 'lxml') folder =soup.title.text[:-32] folderutf = folder.encode("utf-8") folderutf = folderutf.decode('utf-8') print(' '+str(num)+'、'+titles[num-1]+'') soup = BeautifulSoup(html.text, 'html.parser') #part_picURL = re.findall("src='http://img(.+?\.jpg)' type='image'>",html.text,re.S) part_picURL = re.findall(r"src='([a-zA-Z0-9|/|www.|.com|:|_|\?|\.\=]+?)(\.|&)(jpg|gif|png|JPG|PNG|GIF)' type='image'>",html.text,re.S) headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'} sufs=[] for each in part_picURL: picURL = each[0]+each[1]+each[2] suf=each[2] urls.append(picURL) sufs.append(suf) length=len(urls) #print(urls) threads=[]; title=re.sub(r'[\?|\\|\/|\>|\|\.+?",mhtml.text,re.S) titles=[]; effect=[]; links=[]; if(page==1): start=9 else: start=0 for n in range(start,len(part_siteURL)-1): link=re.findall(r"htm_data.+?\.html",part_siteURL[n],re.S) if not len(link)==0: link=site+'/'+link[0] # https://www.baidu.com/ effect.append(n) links.append(link) title=re.findall(r"

()*(.+?)<./>

",part_siteURL[n],re.S) title=title[0][1] titles.append(title) for s in range(0,len(effect)-1): print(str(s+1)+'、'+titles[s]) return titles; def getpic(page,dic,site,filepath): for num in dic: getall(page,num,site,filepath) return; def downimgs(url,path,k): global G; try: downIMG(url,path) print(" "+str(G+1)+" 。") # print(path) G=G+1; except: print(" %d 。"%(G+1)) G=G+1; def enc(src,enc,key): src=open(src, 'rb') enc=open(enc, 'wb') b=src.read(1) while (b!=b''): bi=ord(b)^(key) enc.write(bytes([bi])) b=src.read(1) enc.close() print(' !') def dec(enc,dec,key): enc=open(enc, 'rb') dec=open(dec, 'wb') b=enc.read(1) while (b!=b''): bi=ord(b)^(key) dec.write(bytes([bi])) b=enc.read(1) dec.close() print(' !') def compress(get_files_path, set_files_path): f = zipfile.ZipFile(set_files_path , 'w', zipfile.ZIP_DEFLATED ) for dirpath, dirnames, filenames in os.walk( get_files_path ): fpath = dirpath.replace(get_files_path,'') fpath = fpath and fpath + os.sep or '' for filename in filenames: f.write(os.path.join(dirpath,filename), fpath+filename) f.close() #************************************************************************************# b=a.split(',') lis=[]; n=0; for e in b: finde=re.findall(r'(^[0-9]+?$|^[0-9]+?-[0-9]+$)',e) #print(finde) if len(finde)==1: if e.find('-')==-1: if int(e)(len(titles)-1) or int(ch[0][1]))<1 or int(ch[0][1])>(len(titles)-1)): if(n==0): print(" !",end='') n=1; else: lis.append(range(int(ch[0][0]),int(ch[0][1]))) else: print(" !") #************************************************************************************#

좋은 웹페이지 즐겨찾기