博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How to Use Reptile for iOS Programmer
阅读量:6002 次
发布时间:2019-06-20

本文共 2512 字,大约阅读时间需要 8 分钟。

hot3.png

Just find a funny article about iOS programmer to write reptile, everyone, just for fun, I will not be responsibility for any issue in law.

Use the code with Python, you can do it, so please learn python!

#!/usr/bin/python#-*- coding: utf-8 -*-#encoding=utf-8import urllib2import urllibimport osfrom BeautifulSoup import BeautifulSoupdef getAllImageLink():    html = urllib2.urlopen('http://www.dbmeizi.com').read()    soup = BeautifulSoup(html)    liResult = soup.findAll('li',attrs={"class":"span3"})    for li in liResult:        imageEntityArray = li.findAll('img')        for image in imageEntityArray:            link = image.get('data-src')            imageName = image.get('data-id')            filesavepath = '/Users/weihua0618/Desktop/meizipicture/%s.jpg' % imageName             urllib.urlretrieve(link,filesavepath)            print filesavepath if __name__ == '__main__':    getAllImageLink()
You should modify the file's path wrote in the code, also you should create the directory in the path, otherwise you will get some error like this:
Traceback (most recent call last):  File "pictures.py", line 21, in 
getAllImageLink() File "pictures.py", line 9, in getAllImageLink html = urllib2.urlopen('http://www.dbmeizi.com').read() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 127, in urlopen return _opener.open(url, data, timeout) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 404, in open response = self._open(req, data) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 422, in _open '_open', req) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 382, in _call_chain result = func(*args) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1214, in http_open return self.do_open(httplib.HTTPConnection, req) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1184, in do_open raise URLError(err)urllib2.URLError:

Reference:

Good luck!

BUT, this way for getting info from network is important, we can use it in the project. For example, we can use it to get many pictures( or the other resource, e.g: novel, joke etc ), and save them into the database, then we can use it in many clients, oh, god, it is a new door for me!

转载于:https://my.oschina.net/u/913344/blog/380876

你可能感兴趣的文章
本学习笔记TCP/IP传输协议
查看>>
荣耀10GT升级EMUI 9.0体验分享:这可能是最好用的手机操作系统
查看>>
ZStack基于华芯通打造ARM国产云平台 助力云上贵州多项应用
查看>>
200本“保护日记”记录黄山迎客松生长变化
查看>>
多方力量携手呵护“中华水塔”青海三江源
查看>>
互联网的下一波红利在哪里?
查看>>
拿姐姐身份证登记结婚竟然成了!婚姻户籍信息共享难在哪儿
查看>>
JAVA大神说一个例子让你几分钟学会Annotation
查看>>
【进阶2-3期】JavaScript深入之闭包面试题解
查看>>
【Chrome扩展开发】定制HTTP请求响应头域
查看>>
面向Vue新人:写一个简单的倒计时按钮
查看>>
关于手势处理
查看>>
super
查看>>
5G美洲白皮书:5G开源的现状(pdf)
查看>>
世界移动通信大会
查看>>
基于Spring Security Role过滤Jackson JSON输出内容
查看>>
从设计者的角度看 React
查看>>
js常见问题
查看>>
CentOS6系统编译部署LAMP(Linux, Apache, MySQL, PHP)环境
查看>>
海量大数据大屏分析展示一步到位:DataWorks数据服务对接DataV最佳实践
查看>>