荆门自学编程在线课程方法有时,相同的图形链,一段时间后抓住,或改变网络。我猜它是反向爬行的,但证据不足,所以爬行频率只能降低,比如每次发送和接收POST请求便10s左右,但还是会有失败。如果你有更好的意见,欢迎交流。目前正常情况100%爬没问题,90%以上异常情况。
#!/usr/bin/env python# -*- coding:utf-8 -*-# date: 2018.03.07"""Capte pictes fm lofter with username."""import reimport osimport platformimport requestsimport timeimport randomdef _get_path(username):
path = { 'Windows': 'D:/litreily/Pictes/python/lofter/' username, 'Linux': '/mnt/d/litreily/Pictes/python/lofter/' username
pnt('The blogid of %s is: %s' % (username, blogid)) retn blogid except Exception as e:
timestamp = time_pattern.search(html).gup(1) retn str(timestamp)def _get_imgls(username, blog, headers):
pnt('Blog\t%s\ith %d\tpictes' % (blog_l, len(imgls))) retn imglsdef _capte_images(imgl, path):