python在多玩圖片上下載妹子圖的實現(xiàn)代碼
# -*- coding:utf-8 -*-
import httplib
import urllib
import string
import re
def getContent(): #從網站中獲取所有內容
conn = httplib.HTTPConnection("tu.duowan.com")
conn.request("GET", "/m/meinv/index.html")
r = conn.getresponse()
print r.status, r.reason
data1 = r.read()#.decode('utf-8') #編碼根據(jù)實際情況酌情處理
return data1
def getImageUrl(data): #將獲取到img鏈接寫到sour.txt文件中國
sour = open("test\\sour.txt", 'w')
pplen = len("http://s1.dwstatic.com/group1/M00/37/2A/e2c30e89184ea942a4be9c1f7ba217a5.jpg")
for i in range(len(data) - 3):
if data[i] == 'i' and data[i + 1] == 'm' and data[i + 2] == 'g':
for j in xrange(i + 9, i + 9 + pplen):
sour.write(data[j])
sour.write('\n')
sour.close()
def downImage(): #根據(jù)test\\sour.txt里面的url自動下載圖片
tt = 0 #name
sour = open('test\\sour.txt')
while 1:
line = sour.readline()
if line:
Len = len(line)
#print Len
if line[Len - 2] == 'g' and line[Len - 3] == 'p' and line[Len - 4] == 'j':
path = line
data = urllib.urlopen(line).read()
f = open('test\\' + str(tt) + '.jpg', 'wb')
f.write(data)
f.close()
tt = tt + 1
else:
break
sour.close()
content = getContent()
getImageUrl(content)
downImage()
相關文章
python selenium 獲取接口數(shù)據(jù)的實現(xiàn)
這篇文章主要介紹了python selenium 獲取接口數(shù)據(jù)的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-12-12
Python3.7基于hashlib和Crypto實現(xiàn)加簽驗簽功能(實例代碼)
這篇文章主要介紹了Python3.7基于hashlib和Crypto實現(xiàn)加簽驗簽功能,環(huán)境是基于python3.7,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-12-12
PyTorch詳解經典網絡種含并行連結的網絡GoogLeNet實現(xiàn)流程
今天小編就為大家分享一篇Pytorch實現(xiàn)GoogLeNet的方法,GoogLeNet提出了一個名為“Inception”的深度卷積神經網結構,其目標是將分類、識別ILSVRC14數(shù)據(jù)集的技術水平提高一個層次。這一結構的主要特征是對網絡內部計算資源的利用進行了優(yōu)化2022-05-05
Python Flask搭建yolov3目標檢測系統(tǒng)詳解流程
YOLOv3沒有太多的創(chuàng)新,主要是借鑒一些好的方案融合到YOLO里面。不過效果還是不錯的,在保持速度優(yōu)勢的前提下,提升了預測精度,尤其是加強了對小物體的識別能力2021-11-11

