Python3模拟登录并爬取表格数据!做表格的高手也没我厉害!

Python3模拟登录并爬取表格数据 主要内容有: 通过requests库模拟表单提交 通过pandas库提取网页表格 朋友发给我一个网址,哭哭啼啼地求我:“去!把这个网页上所有年所有县所有作物的数据全爬下来,存到Access里!” 我看他可怜,勉为其难地挥挥手说:“好嘞,马上就开始!” 目标分析 朋友给我的网址是这个:https://www.ctic.org/crm?tdsourcetag=s_pctim_aiomsg 打开长这... 阅读详情

主要内容有:

  • 通过requests库模拟表单提交
  • 通过pandas库提取网页表格

朋友发给我一个网址,哭哭啼啼地求我:“去!把这个网页上所有年所有县所有作物的数据全爬下来,存到Access里!”

我看他可怜,勉为其难地挥挥手说:“好嘞,马上就开始!”

大家在学python的时候肯定会遇到很多难题,以及对于新技术的追求,这里推荐一下我们的Python学习扣qun:784758214,这里是python学习者聚集地!!同时,自己是一名高级python开发工程师,从基础的python脚本到web开发、爬虫、django、数据挖掘等,零基础到项目实战的资料都有整理。送给每一位python的小伙伴!每日分享一些学习的方法。和需要注意的小细节

目标分析

朋友给我的网址是这个: https://www.ctic.org/crm?tdsourcetag=s_pctim_aiomsg

打开长这样:

 

 

 

 

Python资源共享群:484031800

根据我学爬虫的经验,通常只要把年月日之类的参数附加到url里面去,然后用 requests.get 拿到 response 解析html就完了,所以这次应该也差不多——除了要先想办法获得具体有哪些年份、地名、作物名称,其他部分拿以前的代码稍微改改就能用了,毫无挑战性工作,生活真是太无聊了

点击 View Summary 后出现目标网页长这样

 

 

 

 

 

那个大表格的数据就是目标数据了,好像没什么了不起的——

有点不对劲

目标数据所在网页的网址是这样的: https://www.ctic.org/crm/?action=result ,刚刚选择的那些参数并没有作为url的参数啊!网址网页都变了,所以也不是ajax

这和我想象的情况有

巨大 差别啊

尝试获取目标页面

让我来康康点击 View Summary 这个按钮时到底发生了啥:右键 View Summary 检查是这样:

 

 

 

 

 

实话说,这是我第一次遇到要提交表单的活儿。以前可能是上天眷顾我,统统 get 就能搞定,今天终于让我碰上一个 post 了。

点击 View Summary ,到DevTools里找network第一条:

 

 

 

 

 

不管三七二十一, post 一下试试看

import requests
url  =  'https://www.ctic.org/crm?tdsourcetag=s_pctim_aiomsg'
headers  =  {'user-agent':  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
 'AppleWebKit/537.36 (KHTML, like Gecko) '
 'Chrome/74.0.3729.131 Safari/537.36',
 'Host':  'www.ctic.org'}
data  =  {'_csrf':  'SjFKLWxVVkkaSRBYQWYYCA1TMG8iYR8ReUYcSj04Jh4EBzIdBGwmLw==',
        'CRMSearchForm[year]':  '2011',
        'CRMSearchForm[format]':  'Acres',
        'CRMSearchForm[area]':  'County',
        'CRMSearchForm[region]':  'Midwest',
        'CRMSearchForm[state]':  'IL',
        'CRMSearchForm[county]':  'Adams',
        'CRMSearchForm[crop_type]':  'All',
        'summary':  'county'}
response  =  requests.post(url,  data=data,  headers=headers)
print(response.status_code)

果不其然,输出 400 ……我猜这就是传说中的 cookies 在搞鬼吗?《Python3网络爬虫实战》只看到第6章的我不禁有些

心虚 跃跃欲试呢!

首先,我搞不清 cookies 具体是啥,只知道它是用来维持会话的,应该来自于第一次 get ,搞出来看看先:

response1  =  requests.get(url,  headers=headers)
if  response1.status_code  ==  200:
    cookies  =  response1.cookies
    print(cookies)

输出:

<RequestsCookieJar[<Cookie PHPSESSID=52asgghnqsntitqd7c8dqesgh6  for  www.ctic.org/>,  <Cookie _csrf=2571c72a4ca9699915ea4037b967827150715252de98ea2173b162fa376bad33s%3A32%3A%22TAhjwgNo5ElZzV55k3DMeFoc5TWrEmXj%22%3B  for  www.ctic.org/>]>

Nah,看不懂,不看不管,直接把它放到 post 里试试

response2  =  requests.post(url,  data=data,  headers=headers,  cookies=cookies)
print(response2.status_code)

还是 400 ,气氛突然变得有些焦灼,我给你 cookies 了啊,你还想要啥?!

突然,我发现一件事: post 请求所带的 data 中那个一开始就显得很可疑的 _csrf 我仿佛在哪儿见过?

那个我完全看不懂的 cookies 里好像就有一个 _csrf 啊!但是两个 _csrf 的值很明显结构不一样,试了一下把 data 里的 _csrf 换成 cookies 里的 _csrf 确实也不行。

但是我逐渐有了一个想法:这个两个 _csrf 虽然不相等,但是应该是匹配的,我刚刚的 data 来自浏览器, cookies 来自python程序,所以不匹配!

于是我又点开浏览器的DevTools,Ctrl+F搜索了一下,嘿嘿,发现了:

 

 

 

 

 

和

 

 

 

 

 

这三处。

第一处那里的下一行的 csrf_token 很明显就是 post 请求所带的 data 里的 _csrf ,另外两个是js里的函数,虽然js没好好学但也能看出来这俩是通过 post 请求获得州名和县名的,Binggo!一下子解决两个问题。

为了验证我的猜想,我打算先直接用requests获取点击 View Summary 前的页面的HTML和 cookies ,将从HTML中提取的 csrf_token 值作为点击 View Summary 时 post 请求的 data 里的 _csrf 值,同时附上 cookies ,这样两处 _csrf 就应该是匹配的了:

from lxml import etree
response1  =  requests.get(url,  headers=headers)
cookies  =  response1.cookies
html  =  etree.HTML(response1.text)
csrf_token  =  html.xpath('/html/head/meta[3]/@content')[0]
data.update({'_csrf':  csrf_token})
response2  =  requests.post(url,  data=data,  headers=headers,  cookies=cookies)
print(response2.status_code)

输出 200 ,虽然和Chrome显示的 302 不一样,但是也表示成功,那就不管了。把 response2.text 写入html文件打开看是这样:

 

 

 

 

 

Yeah,数据都在!说明我的猜想是对的!那一会再试试我从没用过的 requests.Session() 维持会话,自动处理 cookies 。

尝试pandas库提取网页表格

现在既然已经拿到了目标页面的HTML,那在获取所有年、地区、州名、县名之前,先测试一下 pandas.read_html 提取网页表格的功能。

pandas.read_html 这个函数时在写代码时IDE自动补全下拉列表里瞄到的,一直想试试来着,今天乘机拉出来溜溜:

import pandas as  pd
df  =  pd.read_html(response2.text)[0]
print(df)

输出:

 

 

 

 

 

Yeah!拿到了,确实比自己手写提取方便,而且数值字符串自动转成数值,优秀!

准备所有参数

接下来要获取所有年、地区、州名、县名。年份和地区是写死在HTML里的,直接xpath获取:

 

 

 

 

 

州名、县名根据之前发现的两个js函数,要用 post 请求来获得,其中州名要根据地区名获取,县名要根据州名获取,套两层循环就行

def new():
    session  =  requests.Session()
    response  =  session.get(url=url,  headers=headers)
    html  =  etree.HTML(response.text)
    return  session,  html
session,  html  =  new()
years  =  html.xpath('//*[@id="crmsearchform-year"]/option/text()')
regions  =  html.xpath('//*[@id="crmsearchform-region"]/option/text()')
_csrf  =  html.xpath('/html/head/meta[3]/@content')[0]
region_state  =  {}
state_county  =  {}
for  region in  regions:
    data  =  {'region':  region,  '_csrf':  _csrf}
    response  =  session.post(url_state,  data=data)
    html  =  etree.HTML(response.json())
    region_state[region]  =  {x:  y  for  x,  y  in
                            zip(html.xpath('//option/@value'),
                                html.xpath('//option/text()'))}
    for  state in  region_state[region]:
        data  =  {'state':  state,  '_csrf':  _csrf}
        response  =  session.post(url_county,  data=data)
        html  =  etree.HTML(response.json())
        state_county[state]  =  html.xpath('//option/@value')

啧啧,使用 requests.Session 就完全不需要自己管理 cookies 了,方便!具体获得的州名县名就不放出来了,实在太多了。然后把所有年、地区、州名、县名的可能组合先整理成csv文件,一会直接从csv里读取并构造 post 请求的 data 字典:

remain  =  [[str(year),  str(region),  str(state),  str(county)]
 for  year in  years for  region in  regions
 for  state in  region_state[region]  for  county in  state_county[state]]
remain  =  pd.DataFrame(remain,  columns=['CRMSearchForm[year]',
 'CRMSearchForm[region]',
 'CRMSearchForm[state]',
 'CRMSearchForm[county]'])
remain.to_csv('remain.csv',  index=False)
# 由于州名有缩写和全称,也本地保存一份
import json
with open('region_state.json',  'w')  as  json_file:
        json.dump(region_state,  json_file,  indent=4)

我看了一下,一共49473行——也就是说至少要发送49473个 post 请求才能爬完全部数据,纯手工获取的话大概要点击十倍这个数字的次数……

正式开始

那么开始爬咯

import pyodbc
with open("region_state.json")  as  json_file:
    region_state  =  json.load(json_file)
data  =  pd.read_csv('remain.csv')
# 读取已经爬取的
cnxn  =  pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
                      'DBQ=./ctic_crm.accdb')
crsr  =  cnxn.cursor()
crsr.execute('select Year_, Region, State, County from ctic_crm')
done  =  crsr.fetchall()
done  =  [list(x)  for  x  in  done]
done  =  pd.DataFrame([list(x)  for  x  in  done],  columns=['CRMSearchForm[year]',
                                                      'CRMSearchForm[region]',
                                                      'CRMSearchForm[state]',
                                                      'CRMSearchForm[county]'])
done['CRMSearchForm[year]']  =  done['CRMSearchForm[year]'].astype('int64')
state2st  =  {y:  x  for  z  in  region_state.values()  for  x,  y  in  z.items()}
done['CRMSearchForm[state]']  =  [state2st[x]
                                for  x  in  done['CRMSearchForm[state]']]
# 排除已经爬取的
remain  =  data.append(done)
remain  =  remain.drop_duplicates(keep=False)
total  =  len(remain)
print(f'{total} left.n')
del data
# %%
remain['CRMSearchForm[year]']  =  remain['CRMSearchForm[year]'].astype('str')
columns  =  ['Crop',
 'Total_Planted_Acres',
 'Conservation_Tillage_No_Till',
 'Conservation_Tillage_Ridge_Till',
 'Conservation_Tillage_Mulch_Till',
 'Conservation_Tillage_Total',
 'Other_Tillage_Practices_Reduced_Till15_30_Residue',
 'Other_Tillage_Practices_Conventional_Till0_15_Residue']
fields  =  ['Year_',  'Units',  'Area',  'Region',  'State',  'County']  +  columns
data  =  {'CRMSearchForm[format]':  'Acres',
        'CRMSearchForm[area]':  'County',
        'CRMSearchForm[crop_type]':  'All',
        'summary':  'county'}
headers  =  {'user-agent':  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
 'AppleWebKit/537.36 (KHTML, like Gecko) '
 'Chrome/74.0.3729.131 Safari/537.36',
 'Host':  'www.ctic.org',
 'Upgrade-Insecure-Requests':  '1',
 'DNT':  '1',
 'Connection':  'keep-alive'}
url  =  'https://www.ctic.org/crm?tdsourcetag=s_pctim_aiomsg'
headers2  =  headers.copy()
headers2  =  headers2.update({'Referer':  url,
                            'Origin':  'https://www.ctic.org'})
def new():
    session  =  requests.Session()
    response  =  session.get(url=url,  headers=headers)
    html  =  etree.HTML(response.text)
    _csrf  =  html.xpath('/html/head/meta[3]/@content')[0]
    return  session,  _csrf
session,  _csrf  =  new()
for  _,  row in  remain.iterrows():
    temp  =  dict(row)
    data.update(temp)
    data.update({'_csrf':  _csrf})
    while  True:
        try:
            response  =  session.post(url,  data=data,  headers=headers2,  timeout=15)
            break
        except Exception as  e:
            session.close()
            print(e)
            print('nSleep 30s.n')
            time.sleep(30)
            session,  _csrf  =  new()
            data.update({'_csrf':  _csrf})
    df  =  pd.read_html(response.text)[0].dropna(how='all')
    df.columns  =  columns
    df['Year_']  =  int(temp['CRMSearchForm[year]'])
    df['Units']  =  'Acres'
    df['Area']  =  'County'
    df['Region']  =  temp['CRMSearchForm[region]']
    df['State']  =  region_state[temp['CRMSearchForm[region]']][temp['CRMSearchForm[state]']]
    df['County']  =  temp['CRMSearchForm[county]']
    df  =  df.reindex(columns=fields)
    for  record in  df.itertuples(index=False):
        tuple_record  =  tuple(record)
        sql_insert  =  f'INSERT INTO ctic_crm VALUES {tuple_record}'
        sql_insert  =  sql_insert.replace(', nan,',  ', null,')
        crsr.execute(sql_insert)
        crsr.commit()
    print(total,  row.to_list())
    total  -=  1
else:
    print('Done!')
    crsr.close()
    cnxn.close()

注意中间有个 try...except.. 语句,是因为不定时会发生 Connection aborted 的错误,有时9000次才断一次,有时一次就断,这也是我加上了 读取已经爬取的 和 排除已经爬取的 原因,而且担心被识别出爬虫,把 headers 写的丰富了一些(好像并没有什么卵用),并且每次断开都暂停个30s并重新开一个会话

 

 

 

 

 

然后把程序开着过了一个周末,命令行里终于打出了 Done! ,到Access里一看有816288条记录,心想:下次试试多线程(进程)和代理池。 

Python爬取多网页表格数据(非table) 阅读详情

相关推荐

python 获取网页表格的方法(多种方法汇总)

我们在网页上看到很多的表格,如果要获取里面的数据或者转化成其他格式,就需要将表格获取下来并进行整理。以下是不同的方法来获取网页的表格!

Meggie35的博客 2525

python接口自动化封装导出excel方法和读写excel数据

值得注意的是,我用的是python内置库xlrd读写excel文件,xls格式文件xlrd可以读写,且xlrd使用1.几的版本,最新版本不支持xls文件,openpyxl库只支持xlsx格式文件。如下:我们先看下不对返回结果做处理,直接接收数据类型是一个对象,无法获取返回值。一、首先需要思考,我们在页面导出excel,用python导出如何写入文件的。封装前需要确认python导出excel接口返回的是一个什么样的数据类型。如上,先接收二进制文件,然后使用操作excel方法‘wb’写入二进制文件。

Gefangenes的博客 284

【爬虫】Python实现爬取淘宝商品信息(超详细)

项目基于Python的第三方库Selenium模拟浏览器运行、PyQuery解析和操作HTML文档,获取淘宝平台中某类商品的详细信息(商品标题、价格、销量、商铺名称、地区、商品详情页链接、商铺链接等),并基于第三方库openpyxl建立、存储于Excel表格中。# 全局变量count = 1 # 写入Excel商品计数# 启动ChromeDriver服务# 关闭自动测试状态显示 // 会导致浏览器报:请停用开发者模式# 把chrome设为selenium驱动的浏览器代理;# 窗口最大化。

qq_46315152的博客 4万+

Pathon爬取2345天气网天气数据

Python 爬取2345天气网数据,并对解析错误的数据进行修复处理。 用到的库:Requests,BeautifulSoup,Pandas.

6438

Python模拟登录实战,采集整站表格数据!

本节主要内容有: 通过requests库模拟表单提交 通过pandas库提取网页表格 上周五,大师兄发给我一个网址,哭哭啼啼地求我:“去!把这个网页上所有年所有县所有作物的数据全爬下来,存到Access里!” 我看他可怜,勉为其难地挥挥手说:“好嘞,马上就开始!” 目标分析 大师兄给我的网址是这个:https://www.ctic.org/crm?tdsourcetag=s_pctim_aiomsg 打开长这样: 根据我学爬虫并不久的经验,通常只要把年月日之类的参数附加到url里面去,然后

pythonlaodi的博客 313

使用Python中的pandas库来爬取网页中包含表格的数据是一种常见的数据爬取任务

使用Python中的pandas库来爬取网页中包含表格的数据是一种常见的数据爬取任务。通过使用pandas库,我们可以轻松地将网页中的表格数据提取出来,并进行进一步的分析和处理。一旦我们获取了网页的内容,我们可以使用BeautifulSoup库来解析HTML,并找到包含表格数据的HTML元素。通过以上代码,我们可以轻松地使用pandas库来爬取网页中包含表格的数据。现在,我们已经成功找到了包含表格数据的HTML元素。安装完成后,我们可以开始编写Python代码来实现网页数据的爬取和表格数据的提取。

TechSavant的博客 402

为什么有些xpath绝对路径拿不到数据_Python3模拟登录并爬取表格数据!做表格的高手也没我厉害!...

主要内容有:通过requests库模拟表单提交通过pandas库提取网页表格朋友发给我一个网址,哭哭啼啼地求我:“去!把这个网页上所有年所有县所有作物的数据全爬下来,存到Access里!”我看他可怜,勉为其难地挥挥手说:“好嘞,马上就开始!”目标分析朋友给我的网址是这个: https://www.ctic.org/crm?tdsourcetag=s_pctim_aiomsg打开长这样:Python...

weixin_33677704的博客 137

【G4基础03】2.3 How to Specify Materials in the Detector

定义探测器材料

adelall的博客 490

Python3 模拟登录并爬取表格数据!

本节主要内容有: 通过requests库模拟表单提交 通过pandas库提取网页表格 上周五,大师兄发给我一个网址,哭哭啼啼地求我:“去!把这个网页上所有年所有县所有作物的数据全爬下来,存到Access里!” 我看他可怜,勉为其难地挥挥手说:“好嘞,马上就开始!” 目标分析 Python学习交流群:1004391443 大师兄给我的网址是这个: https://www.ctic.org...

Pythoncxy的博客 7317

SAP S4业务伙伴(BP)实战指南:从角色分配到数据同步的完整流程

本文详细解析了SAP S4业务伙伴(BP)功能,从基础概念到实战操作,涵盖角色分配、数据同步及常见问题排查。通过BP机制,企业可高效管理客户、供应商等多重身份,实现数据共享和动态切换,显著提升主数据管理效率。特别适合SAP实施顾问和ERP管理员参考。

y2z3a4b5c的博客 870

深入解析Android SoundTrigger架构:从HIDL到AIDL的演进与实践

本文深入解析Android SoundTrigger架构,从HIDL到AIDL的演进与实践。SoundTrigger是Android系统中低功耗语音唤醒的关键技术,通过分层设计和硬件协同实现高效语音识别。文章详细介绍了核心组件、HIDL与AIDL的对比及优化技巧,帮助开发者掌握语音模型优化和功耗管理。

brown的博客 231

学会Python3模拟登录并爬取表格数据!excel高手也自叹不如!

不知道你们用的什么环境,我一般都是用的Python3.6环境和pycharm解释器,没有软件,或者没有资料,没人解答问题,都可以免费领取(包括今天的代码),过几天我还会做个视频教程出来,有需要也可以领取~给大家准备的学习资料包括但不限于:Python 环境、pycharm编辑器/永久激活/翻译插件python 零基础视频教程Python 界面开发实战教程Python 爬虫实战教程Python 数据分析实战教程python 游戏开发实战教程Python 电子书100本。

m0_60607895的博客 1046

ESP32搭配FT6236触摸屏:从芯片手册到完整I2C驱动代码的保姆级解析

本文详细解析了ESP32搭配FT6236触摸屏的I2C驱动开发过程,从芯片手册解读到完整代码实现。通过硬件架构分析、寄存器配置、I2C通信封装及触摸数据处理等步骤,提供了一套完整的驱动解决方案,帮助开发者快速掌握ESP32与触摸屏的交互技术。

weixin_29174385的博客 295

学会Python3模拟登录并爬取表格数据!excel高手也自叹不如!(1)

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!因此收集整理了一份《2024年最新Python全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。 既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Python知识点,真正体系化!由于文件比较多,这里只是将部分目录截图出来,全套

m0_60635321的博客 948

基于Dify1.9知识库流水线模板的思考——图像和表格数据处理

本文探讨了Dify1.9知识库流水线中LLM节点对文档图像/表格增强处理的优化方案。针对当前仅在内容后追加说明的简单做法,提出了结构化标注的改进方法:通过唯一ID和注释块标记图像/表格及其描述,确保内容可精准对齐。文章详细阐述了该方案的解析处理流程、数据结构化表示方法,以及在RAG检索和文档还原中的具体应用。关键经验包括:必须结构化标注非文本内容、LLM增强的必要性、语义向量化处理等。该方案解决了原始方法在内容重排、相似元素区分和检索精度等方面的问题。

roseey的专栏 1440

2025年CSP-J复赛真题及题解:T4 多边形(polygon)

2025年CSP-J复赛真题及题解:T4 多边形(polygon)

王老师青少年编程 1719

python模拟浏览器操作爬取业务分页表格数据

EC.presence_of_element_located((By.CSS_SELECTOR, "input[placeholder='请输入用户名']"))"download.default_directory": r"D:\study\python\demo\directory", # 修改为您的下载路径。headers = ["序号", "银行名称", "银行简称","排序", "状态", "类型", "备注", "操作"] # 手动指定表头。print("未捕获到任何数据")

shisuizhe的专栏 1670

Windows密码忘了怎么办?一分钟看懂Windows密码底层机制:无需重装系统也能无痕找回登录密码

忘记Windows开机密码,不一定非得重装系统!本文手把手教你通过提取NTLM Hash值实现“无痕找回密码”,无需PE、无需清除密码,对系统零修改 🛡️ 搭配mimikatz与在线解密平台,小白也能快速上手,了解Windows密码底层机制 🔐

XiaoqiangClub的博客 126

Python3 模拟登录并爬取表格数据

据我了解,通常只要把年月日之类的参数附加到url里面去,然后用requests.get拿到response解析html就完了,所以这次应该也差不多——除了要先想办法获得具体有哪些年份、地名、作物名称,其他部分拿以前的代码稍微改改就能用了

1219

21、深入了解SELinux安全系统与/proc文件系统

本文深入探讨了SELinux安全系统与/proc文件系统的原理及实际应用。详细介绍了SELinux的安全上下文、域转换、运行模式、角色管理以及策略查看工具seinfo的使用;同时解析了/proc文件系统的结构与功能,涵盖进程信息查看、系统资源监控及性能优化方法。结合SELinux与/proc的协同应用,提供了系统问题排查流程与安全管理最佳实践,帮助用户提升Linux系统的安全性与稳定性。

ik678901234的博客 63

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

python模拟登录爬取数据_Python3 模拟登录并爬取表格数据!

本节主要内容有:通过requests库模拟表单提交通过pandas库提取网页表格上周五,大师兄发给我一个网址,哭哭啼啼地求我:“去!把这个网页上所有年所有县所有作物的数据全爬下来,存到Access里!”我看他可怜,勉为其难地挥挥手说:“好嘞,马上就开始!”目标分析Python学习交流群:1004391443打开长这样:根据我学爬虫并不久的经验,通常只要把年月日之类的参数附加到url里面去,然后用 ...

weixin_39570505的博客 407

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

python3和burpsuite组合爬取网页数据并存储在excel表格(需要登录后才能看到的大量数据)

目录前言环境思路:第一步获取Response数据1、先使用burpsuite抓包,看一下header请求头2、使用burpsuite的intruder模块遍历所有page值获取所有的Response。3、查看响应包重要数据格式4、保存所有需要的Response数据包5、使用python提取数据思路:第二步 使用python正则表达式获取Response中重要数据,并格式化输出到txt1、python正则表达式3、文件读取4、数据提取5、格式化输出6、格式化后的数据以追加的形式写入文件7、最终脚本思路:第三步

ch4nge 2300

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

python模拟excel登录插件_学会Python3模拟登录并爬取表格数据!excel高手也自叹不如!...

主要内容有:通过requests库模拟表单提交通过pandas库提取网页表格朋友发给我一个网址,哭哭啼啼地求我:“去!把这个网页上所有年所有县所有作物的数据全爬下来,存到Access里!”我看他可怜,勉为其难地挥挥手说:“好嘞,马上就开始!”大家在学python的时候肯定会遇到很多难题,以及对于新技术的追求,这里推荐一下我们的Python学习扣qun:631441315,这里是python学习者聚...

weixin_39767121的博客 172
上一篇: Python 中拼音库 PyPinyin 的用法!这个库有点意思哈!
下一篇: 基于Python和Xtrbackup的自动化备份与还原实现!
普通网友
博客等级 码龄7年 438粉丝 263原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值