在GAE中用Python编写webapp进行Post数据采集
#!/usr/bin/env python
# -*- coding: cp936 -*-
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import webapp2
#from lxml import etree
from google.appengine.api import urlfetch
import re class MainHandler(webapp2.RequestHandler):
def get(self):
#self.response.write(urlfetch.fetch('https://www.cnblogs.com/').content)#Get
form_data = 'ssss=aaa&bb=ccc'
result = urlfetch.fetch(url='https://www.cnblogs.com',
payload=form_data,
method=urlfetch.POST,
follow_redirects=False,
headers={'Content-Type': 'application/x-www-form-urlencoded'})
#self.response.headers['Content-Type'] = 'application/json'
html="<a href='javascript:void(0)' onclick='opennewpage('54999')'>ddd</a><a onclickk='opennewpage('123456')'>aaa</a>"
reg=r"opennewpage\('(\d+)'\)"#正则
result='Result:<br />'
for m in list(set(re.findall(reg,html))):
result=result+ m+'<br />' self.response.write(result) #ids= result.content.xpath("//a[start-with(@onclick,'opennewpage')]")
#for i in ids:
# print(i.text)
#self.response.write(result.content) app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
在GAE中用Python编写webapp进行Post数据采集的更多相关文章
- [译]Python编写虚拟解释器
使用Python编写虚拟机解释器 一.实验说明 1. 环境登录 无需密码自动登录,系统用户名shiyanlou,密码shiyanlou 2. 环境介绍 本实验环境采用带桌面的Ubuntu Linux环 ...
- 基于python编写的天气抓取程序
以前一直使用中国天气网的天气预报组件都挺好,可是自从他们升级组件后数据加载变得非常不稳定,因为JS的阻塞常常导致网站打开速度很慢.为了解决这个问题决定现学现用python编写一个抓取程序,每天定时抓取 ...
- 用Python编写博客导出工具
用Python编写博客导出工具 罗朝辉 (http://kesalin.github.io/) CC 许可,转载请注明出处 写在前面的话 我在 github 上用 octopress 搭建了个人博 ...
- 【转载】Python编写简易木马程序
转载来自: http://drops.wooyun.org/papers/4751?utm_source=tuicool 使用Python编写一个具有键盘记录.截屏以及通信功能的简易木马. 首先准备好 ...
- 用Python编写的第一个回测程序
用Python编写的第一个回测程序 2016-08-06 def savfig(figureObj, fn_prefix1='backtest8', fn_prefix2='_1_'): import ...
- Hadoop:使用原生python编写MapReduce
功能实现 功能:统计文本文件中所有单词出现的频率功能. 下面是要统计的文本文件 [/root/hadooptest/input.txt] foo foo quux labs foo bar quux ...
- python编写的自动获取代理IP列表的爬虫-chinaboywg-ChinaUnix博客
python编写的自动获取代理IP列表的爬虫-chinaboywg-ChinaUnix博客 undefined Python多线程抓取代理服务器 | Linux运维笔记 undefined java如 ...
- python编写网络抓包分析脚本
python编写网络抓包分析脚本 写网络抓包分析脚本,一个称手的sniffer工具是必不可少的,我习惯用Ethereal,简单,易用,基于winpcap的一个开源的软件 Ethereal自带许多协议的 ...
- RobotFramework自动化测试框架-使用Python编写自定义的RobotFramework Lib
使用Python构建Lib工程 可以用来开发Python Lib的IDE工具有很多,常见的有Pycharm,Eclipse with PyDev插件等,而且在RobotFramework官网中也已经提 ...
随机推荐
- neutron网络服务部署
控制节点执行 #第一步 登陆数据库 mysql -u root -p #导入neutron这个库 CREATE DATABASE neutron; #创建neutron这个用户和密码,并允许本地登陆和 ...
- zencart后台订单详细页显示产品图片和链接
方法一: 找到admin/order.php 大约491行 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { 与 if (iss ...
- heike
黑客工具 hacker disassembler engine download IDApro
- 3.Pod控制器应用进阶
一.Pod的生命周期 init container -- Post start -- running -- pre stop -- main container 创建Pod经历的过程:->a ...
- 2019强网杯web upload分析(pop链)
参考链接:https://blog.csdn.net/qq_41173457/article/details/90724943 注意 只要namespace相同那就可以直接实例化同一namespace ...
- eclipse中没有server选项无法配置Tomcat
eclipse集成Tomcat: 打开eclipse - 窗口 - 首选项 - 服务器 - 运行时环境 找到Tomcat然后添加. eclipse添加插件: 开发WEB项目时要集成Tomcat可以并不 ...
- JS收缩展开效果
// 收缩展开效果 $(document).ready(function () { $(".box h2").toggle(function () { $(this).next(& ...
- vue-router的路由
路由和组件是有区别的:组件一般是在同一个页面的不同模块,但是路由是直接切换到另一个页面,之前的页面销毁. App.vue中的router-view会渲染顶级路由匹配到的组件.组件内部嵌套的router ...
- jquery odd选择器 语法
jquery odd选择器 语法 作用::odd 选择器选取每个带有奇数 index 值的元素(比如 1.3.5).index 值从 0 开始,所有第一个元素是偶数 (0).最常见的用法:与其他元素/ ...
- Devexpress 10
序言 Grid表格 资料 https://www.devexpresscn.com/