chain的实现就是廖老师的代码
flask初始化一个静态网页,地址设置为127.0.0.1:5000/get/taoyuan
demo地址 https://github.com/seeways/PythonDemo
先开启flask,再爬
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017/11/21 0021 # @Author : TaoYuan (1876665310@qq.com) # @Link : http://blog.csdn.net/lftaoyuan Python互助学习qq群:315857408 # @Version : V1.0.0 import urllib.request from test05_custom_class import Chain # 动态拼接url url = "{}{}".format('http://127.0.0.1:5000', Chain().get.taoyuan) request = urllib.request.Request(url) response = urllib.request.urlopen(request) if response.getcode() != 200: print("None!") else: html = response.read() # 如果返回结果不为空 if html is not None: # html = html.decode("utf-8") filename = 'C:\\Users\\Administrator\\Desktop\\test.html' file = open(filename, 'wb') file.write(html) file.close() # print(html) else: print("Maybe The Program is Error!") # 头信息 print(response.info())
Sign in to make a reply
我是世外大帝
chain的实现就是廖老师的代码
flask初始化一个静态网页,地址设置为127.0.0.1:5000/get/taoyuan
demo地址 https://github.com/seeways/PythonDemo
先开启flask,再爬