How to Use Reptile for iOS Programmer
How to Use Reptile for iOS Programmer
BluesChow 发表于3年前
How to Use Reptile for iOS Programmer
  • 发表于 3年前
  • 阅读 20
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

摘要: Reptile, iOS, Python

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!

#-*- coding: utf-8 -*-
import urllib2
import urllib
import os
from BeautifulSoup import BeautifulSoup
def getAllImageLink():
    html = urllib2.urlopen('').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 
            print filesavepath 
if __name__ == '__main__':
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 "", line 21, in <module>
  File "", line 9, in getAllImageLink
    html = urllib2.urlopen('').read()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 127, in urlopen
    return, data, timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 404, in open
    response = self._open(req, data)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 422, in _open
    '_open', req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 382, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1214, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1184, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>


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!

共有 人打赏支持
粉丝 6
博文 143
码字总数 29622
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
* 支付类型