美文网首页
python 爬虫图片

python 爬虫图片

作者: 冰鋒 | 来源:发表于2016-11-20 19:56 被阅读0次
    import requests

    .img='img.png'

    .files={'img':('test.png',open(img,'rb'),'image/png')}

    sdata={'username':username,'content':cont}

    res=requests.post(url,data=sdata,files=files)

    print res.text

    ls=requests.get(url)

    f=open("1.png",'wb')

    f.write(f)

    f.flush()

    f.close()

    #!/usr/bin/python

    #coding=utf-8

    import MySQLdb  

    self.conn = MySQLdb.connect(host='localhost',user='',passwd='',db='0')

    cursor = self.conn.cursor()

    cursor.execute( "INSERT INTO Dem_Picture (PicData) VALUES (%s)" , (MySQLdb.Binary(b)))

    # self.conn.commit()

    # 读取表内图片数据,并写入硬盘文件

    cursor.execute( "SELECT PicData FROM Dem_Picture ORDER BY ID DESC limit 1" )

    d = cursor.fetchone()[0]

    cursor.close()

    f = open( "C:\\22.jpg" , "wb" )

    f.write(d)

    f.close()

    相关文章

      网友评论

          本文标题:python 爬虫图片

          本文链接:https://www.haomeiwen.com/subject/kjeypttx.html