国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python在多玩圖片上下載妹子圖的實(shí)現(xiàn)代碼

2019-11-25 18:38:59
字體:
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:

# -*- coding:utf-8 -*-
import httplib
import urllib
import string
import re
def getContent():                   #從網(wǎng)站中獲取所有內(nèi)容
 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ù)實(shí)際情況酌情處理
 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自動(dòng)下載圖片
 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()

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 三明市| 南城县| 萨迦县| 黔西| 民丰县| 安化县| 清镇市| 监利县| 昌都县| 晋州市| 淮滨县| 宁明县| 绵阳市| 紫阳县| 曲靖市| 志丹县| 高台县| 璧山县| 永城市| 福建省| 商洛市| 四平市| 克拉玛依市| 南溪县| 永济市| 峨眉山市| 孝感市| 双江| 新蔡县| 菏泽市| 磴口县| 什邡市| 荣成市| 济源市| 怀远县| 平乡县| 讷河市| 台东县| 孟州市| 开江县| 清远市|