#!/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. 五、WebSocket 链接

    一.前端代码: <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml& ...

  2. puppet自动化搭建lnmp架构

    puppet自动化安装lnmp架构 3nginx的搭建 mkdir -p /etc/puppet/modules/nginx/{manifests,files} vim /etc/puppet/mod ...

  3. Django学习系列3:创建仓库

    在创建仓库之前,在项目superlists中新建一个Python文件,命名为functional_tests.py,里面的内容如下: # File: functional_test.py # Auth ...

  4. WebDriver+PhantomJs爬虫运用(Java)

    需要的添加的jar包及工具:我这里使用maven来构建项目,添加依赖如下: <dependency> <groupId>org.seleniumhq.selenium</ ...

  5. java——HttpClient 代理模式发送Http Https

    在setProxy()方法中设置代理IP后可以将url中的域名换成这个代理IP. http很简单,但是https这样会报错. 问题:如何使用代理发送https请求? 客户端发送https请求之前会先向 ...

  6. 【shell】文本匹配问题

    原文本通过TITLE分段 TITLE1 xxx yyy TITLE2 xxx yyy hello zzz hello TITLE3 xxx hello 类似于这样的,hello可能有多个,需要打印出含 ...

  7. C2MIF软件使用说明

    1.右击---管理员身份运行 2.打开文件txt---搞定!

  8. sh_07_continue

    sh_07_continue i = 0 while i < 10: # continue 某一条件满足时,不执行后续重复的代码 # i == 3 if i == 3: # 注意:在循环中,如果 ...

  9. Applied Spatiotemporal Data Mining应用时空数据挖掘

    Course descriptionWith the continuing advances of geographic information science and geospatialtechn ...

  10. JAVA语言课堂测试源代码及使用截图

    1源代码 第一部分 package 开学测试.java;class ScoreInformation {String stunumber;String name;double mathematicss ...