文档章节

How to Use Reptile for iOS Programmer

BluesChow
 BluesChow
发布于 2015/02/28 18:11
字数 360
阅读 30
收藏 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
iOS 6.0旋转兼容的那点事

这两天问答系统里,问ios横竖屏切换、还有状态栏旋转的问题有点多,来些小心得,希望遇到的人少走弯路; 先贴官方说明: iOS 6.0 Release Notes: Autorotation is changing in iOS 6. In iOS...

董桉远
2013/04/07
0
1
iOS 获取手机的IP地址(内网与外网)

联系人:石虎 QQ:1224614774 昵称:嗡嘛呢叭咪哄 QQ群:807236138 群称:iOS 技术交流学习群 一、概念 1.先是获取内网IP的方法: #import ifaddrs.h #import arpa/inet.h #import net/if.h #defi...

石虎132
09/13
0
0
arc 与 非arc的编译开关

Use Compiler Flags to Enable and Disable ARC You enable ARC using a new -fobjc-arc compiler flag. You can also choose to use ARC on a per-file basis if it’s more convenient for......

JohnZr
2012/09/18
0
0
如何通过 Common Lisp 调用 iOS simulator 并交互?== 未解决

之前根据 CCL 的教程学会了如何在 Common Lisp 中调用 Cocoa 框架,编写 MAC 应用程序。 最近在考虑如何通过 Common Lisp 调用 Cocoa Touch 框架,开发 iOS 程序(iPhone/iPad),首先需要解...

FreeBlues
2014/06/23
0
0

没有更多内容

加载失败,请刷新页面

加载更多

DeepMind 开源图神经网络的代码

用于支持论文《Relational inductive biases, deep learning, and graph networks》。 github A graph network takes a graph as input and returns a graph as output. The input graph has......

shengjuntu
27分钟前
1
0
python2编码详解、一

以前使用python3没觉的什么,跟着公司使用python2后被编码问题折磨的痛不欲生,好好研究了一下编码问题,参考了很多博文,加入自己的理解,这里只是对编码的介绍,下一篇是python2中编码问题...

hc321
35分钟前
1
0
基于OpenSSL的一些常用加密签名算法

目前包括:MD5、SHA512、DES、RSA加解密、RSA+MD5签名验证算法,在openssl基础上再进行封装,使用简单,头文件需要包含openssl库,可以使用vcpkg自动管理,省去繁琐的配置工程的过程。 该RSA...

LoSingSang
44分钟前
1
0
spring Data JPA

什么是JPA? 全称Java Persistence API,可以通过注解或者XML描述【对象-关系表】之间的映射关系,并将实体对象持久化到数据库中。 为我们提供了: 1)ORM映射元数据:JPA支持XML和注解两种元...

狼王黄师傅
49分钟前
1
0
微信小程序 - 使用七牛云 API 截取第 n 秒图像为封面图

前面分享过七牛的上传操作,在这里说下使用七牛 api 对视频在页面的处理,比如你的视频上传之后获取七牛视频链接,这时候你怎么展示它呢? 在页面可以使用小程序提供的原生组件 video ,可以...

几个栗子
52分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部