文档章节

How to Use Reptile for iOS Programmer

BluesChow
 BluesChow
发布于 2015/02/28 18:11
字数 360
阅读 31
收藏 0

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-8
import urllib2
import urllib
import os
from BeautifulSoup import BeautifulSoup
def 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 <module>
    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: <urlopen error [Errno 8] nodename nor servname provided, or not known>

Reference:

http://www.cocoachina.com/programmer/20150227/11198.html

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!

© 著作权归作者所有

共有 人打赏支持
BluesChow
粉丝 5
博文 163
码字总数 29622
作品 0
深圳
程序员
私信 提问
How to Configure iOS for iPhone and iPad to Use So

The socks proxy I created following Proxy Using SSH Tunnel works very well on both Linux and Windows. However, when I try to configure my iPhone and iPad with iOS, I find iOS do......

sincoder
2014/11/20
0
0
#每日播报# 8月6日 Github 热门项目汇总

这是一份来自美国的网友利用 Github 的 API 获取的每日 Github 上热门项目列表,该网友每天都会发布更新列表。下面是 8月6日的热门项目列表: objective-c ChristianKienle/Core-Data-Editor...

oschina
2014/08/08
6.7K
22
iphone中自定义Universal Framework

大家好, 我有很强烈的欲望来写一点关于这个主题的文章,因为在网络当中关于这个主题的信息实在少得可怜。而且,大多数情况下是错误的或信息不完整,是有误人子弟的感觉。如果你想为iphone写...

长平狐
2012/08/13
1K
0
Framework7 v1.5.0 发布,HTML 移动端框架

Framework7 v1.5.0 发布了,该版本部分更新内容如下: App Root New app parameter to specify app root element, by default is . Useful when using F7 with libraries like Vue or React ......

局长
2016/11/09
3.7K
10
Xamarin iOS 7.9.0 发布,初步支持 iOS 8 beta2

Xamarin iOS 7.9.0 发布,初步支持即将到来的 iOS 8。其他改进如下: iOS Designer support: you will need to update Xamarin Studio and Visual Studio to their Alpha components to be a......

oschina
2014/06/20
2.9K
5

没有更多内容

加载失败,请刷新页面

加载更多

OSChina 周六乱弹 —— 你一口我一口多咬一口是小狗

Osc乱弹歌单(2018)请戳(这里) 【今日歌曲】 @达尔文 :分享Roy Orbison的单曲《She's a Mystery to Me》 《She's a Mystery to Me》- Roy Orbison 手机党少年们想听歌,请使劲儿戳(这里...

小小编辑
今天
31
4
Spring源码学习笔记-1-Resource

打算补下基础,学习下Spring源码,参考书籍是《Spring源码深度解析》,使用版本是Spring 3.2.x,本来想试图用脑图记录的,发现代码部分不好贴,还是作罢,这里只大略记录下想法,不写太细了 ...

zypy333
今天
12
0
RestClientUtil和ConfigRestClientUtil区别说明

RestClientUtil directly executes the DSL defined in the code. ConfigRestClientUtil gets the DSL defined in the configuration file by the DSL name and executes it. RestClientUtil......

bboss
今天
19
0

中国龙-扬科
昨天
4
0
Linux系统设置全局的默认网络代理

更改全局配置文件/etc/profile all_proxy="all_proxy=socks://rahowviahva.ml:80/"ftp_proxy="ftp_proxy=http://rahowviahva.ml:80/"http_proxy="http_proxy=http://rahowviahva.ml:80/"......

临江仙卜算子
昨天
13
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部