#!/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数据采集的更多相关文章

  1. [译]Python编写虚拟解释器

    使用Python编写虚拟机解释器 一.实验说明 1. 环境登录 无需密码自动登录,系统用户名shiyanlou,密码shiyanlou 2. 环境介绍 本实验环境采用带桌面的Ubuntu Linux环 ...

  2. 基于python编写的天气抓取程序

    以前一直使用中国天气网的天气预报组件都挺好,可是自从他们升级组件后数据加载变得非常不稳定,因为JS的阻塞常常导致网站打开速度很慢.为了解决这个问题决定现学现用python编写一个抓取程序,每天定时抓取 ...

  3. 用Python编写博客导出工具

    用Python编写博客导出工具 罗朝辉 (http://kesalin.github.io/) CC 许可,转载请注明出处   写在前面的话 我在 github 上用 octopress 搭建了个人博 ...

  4. 【转载】Python编写简易木马程序

    转载来自: http://drops.wooyun.org/papers/4751?utm_source=tuicool 使用Python编写一个具有键盘记录.截屏以及通信功能的简易木马. 首先准备好 ...

  5. 用Python编写的第一个回测程序

    用Python编写的第一个回测程序 2016-08-06 def savfig(figureObj, fn_prefix1='backtest8', fn_prefix2='_1_'): import ...

  6. Hadoop:使用原生python编写MapReduce

    功能实现 功能:统计文本文件中所有单词出现的频率功能. 下面是要统计的文本文件 [/root/hadooptest/input.txt] foo foo quux labs foo bar quux ...

  7. python编写的自动获取代理IP列表的爬虫-chinaboywg-ChinaUnix博客

    python编写的自动获取代理IP列表的爬虫-chinaboywg-ChinaUnix博客 undefined Python多线程抓取代理服务器 | Linux运维笔记 undefined java如 ...

  8. python编写网络抓包分析脚本

    python编写网络抓包分析脚本 写网络抓包分析脚本,一个称手的sniffer工具是必不可少的,我习惯用Ethereal,简单,易用,基于winpcap的一个开源的软件 Ethereal自带许多协议的 ...

  9. RobotFramework自动化测试框架-使用Python编写自定义的RobotFramework Lib

    使用Python构建Lib工程 可以用来开发Python Lib的IDE工具有很多,常见的有Pycharm,Eclipse with PyDev插件等,而且在RobotFramework官网中也已经提 ...

随机推荐

  1. php 简单删除提示

    下面是别的网友整理的,大同小异.一般通过弹出确认按钮来判断是否继续进入下面的删除页面. 第一种: <a href="javascript:if(confirm('确认删除吗?'))wi ...

  2. Juery入门2

    1.Jquery操作文档 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...

  3. php set_magic_quotes_runtime() 函数过时解决方法

    PHP5.3中 bool set_magic_quotes_runtime ( bool $new_setting )函数过时.把函数: set_magic_quotes_runtime($newse ...

  4. 【HDU3308】LCIS

    题目大意:维护一个长度为 N 的序列,支持单点修改,区间查询最长连续上升子序列的长度. 题解: 线段树维护一段区间左端点开始的 LCIS 长度,右端点开始的 LCIS 长度以及区间最优解.考虑进行合并 ...

  5. 数据结构和算法(java版本)学习指南

    1 数据结构和算法内容介绍 2 数据结构和算法的概述 3 稀疏数组SparseArray

  6. hdu 1724 : Ellipse 【Simpson积分】

    题目链接 题意:给出椭圆方程中的a和b,再给出l.r,求l到r的积分的二倍. 输出时要求精度控制为保留到小数点后3位,如下代码中,eps设为1e-9 1e-8时均TLE,1e-4可以AC,1e-3会W ...

  7. Python 字典(Dictionary)Ⅱ

    删除字典元素 能删单一的元素也能清空字典,清空只需一项操作. 显示删除一个字典用del命令,如下实例: 但这会引发一个异常,因http://www.xuanhe.net/为用del后字典不再存在: 注 ...

  8. Nmap使用及常见的参数选项

    概要 当Nmap不带选项运行时,该选项概要会被输出,最新的版本在这里http://www.insecure.org/nmap/data/nmap.usage.txt.它有助于人们记住最常用的选项,但不 ...

  9. .NET面试题系列(十九)Socket网络异常类型

    序言 资料 异常测试之Socket网络异常

  10. 删除操作——str.subString(0,str.length()-1)

    subString是String的一个方法,格式为: public String substring(int beginIndex, int endIndex)  返回一个新字符串,它是此字符串的一个 ...