#!/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. 一、core 启动设置文件中的错误(启动文件不存在)

    一.启动文件不存在 查看 别人的 原因是

  2. 设备树里面#address-cells 、#size-cells、reg三者的关系

    栗子1: cpus { #address-cells = <>; #size-cells = <>; cpu@ { compatible = "arm,cortex- ...

  3. Codeforces 965 枚举轮数贪心分糖果 青蛙跳石头最大流=最小割思想 trie启发式合并

    A /*#include<cstring>#include<algorithm>#include<queue>#include<vector>#incl ...

  4. Webdriver处理页面元素的方式

    Webdriver执行JavaScript代码的方式 WebDriver driver = new ChromeDriver(); JavascriptExecutor jse = (Javascri ...

  5. vue打包多页报错webpackJsonp is not defined

    找到build→webpack.prod.conf.js→找到HtmlWebpackPlugin插件,添加如下配置即可 chunks: ['manifest', 'vendor', 'app']

  6. 美团点评SQL优化工具SQLAdvisor开源快捷部署

    美团点评SQL优化工具SQLAdvisor开源快捷部署 git clone https://github.com/Meituan-Dianping/SQLAdvisor.gityum install ...

  7. 对items函数的理解

    老师:dict的items应该是把dict转成列表,每个列表元素是一个包含key ,value的dict,元素应该是元组,  {a:1, b:2, c:3}   [(a, 1), (b,2), (c, ...

  8. 扑克牌中的顺子(网易2014.3.16笔试offerP226)

    题目:从扑克牌中随机抽5张牌,判断是不是一个顺子,即这5张牌是不是连续的.2~10为数字本身,A为1,J~K为11,12,13,而大小王可以看成任意数字.(网易要求必须用C完成,可以用C库函数) ja ...

  9. 对云信SDK的研究1

    1.云信大部分用了jq 2.很多接口 3.是可以文档很健全

  10. TTTTTTTTTTTTTTTTTT POJ 1330

    题意:给一个有根树,一个查询节点(u,v)的最近公共祖先: #include <iostream> #include <cstdio> #include <cstring ...