코드 백업
모든 함 수 를 보류 하고 다른 부분 을 삭제 합 니 다. 안녕 히 계 세 요!
# -*- 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(" !")
#************************************************************************************#
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.