资源简介
对上个爬虫代码的补充,主要用于武汉理工大学课表的爬取
代码片段和文件信息
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#author:universtar
#time:18/4/12
from urllib import request
from urllib import parse
from bs4 import BeautifulSoup
import time
import re
#响应头信息
headers = {
‘User-Agent‘:‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/57.0.2987.98 Safari/537.36‘
}
#目标url
url = ‘http://sso.jwc.whut.edu.cn/Certification//login.do‘
#获取原网页返回的html
def get_html(urluserNamepassword):
#添加进入教务处的信息
data = {
‘systemId‘:‘‘
‘xmlmsg‘:‘‘
‘userName‘:userName
‘password‘:password
‘type‘:‘xs‘
}
#将信息格式编码为html格式
data = parse.urlencode(data).encode(‘utf-8‘)
#提交请求
req = request.Request(url=urlheaders=headersdata=data)
response = request.urlopen(req)
#获取网页html代码
html = response.read()
return html
#
def get_info(htmlresponse):
#获得soup对象
soup = BeautifulSoup(htmlresponse ‘html.parser‘ from_encoding=‘utf-8‘)
#从soup对象中截取到所要的信息
infos = soup.find_all(‘div‘style=“margin-top: 2px; font-size: 10px“)
相关资源
- 一个多线程智能爬虫,爬取网站小说
- 基于Python爬虫爬取天气预报信息
- 顶点小说单本书爬虫.py
- 一个简单的python爬虫
- 豆瓣爬虫;Scrapy框架
- 中国城市经纬度爬虫.ipynb
- Python爬虫数据分析可视化
- 网站列表信息爬虫
- 百度图片爬虫(python版)
- python爬取小说59868
- 彼岸花网壁纸爬虫
- Python 爬虫小说.ipynb
- 爬虫爬取网易云音乐
- 北邮python爬虫学堂在线
- python简单爬虫
- 爬取58同城二手房信息.py
- 知网爬虫软件(python)
- python爬虫爬取微博热搜
- python爬虫爬取旅游信息(附源码,c
- python爬虫爬取豆瓣电影信息
- 爬取上百张妹子图源码可直接运行
- Python爬虫实战入门教程
- 网络爬虫(pachong_anjuke.py)
- Python-京东抢购助手包含登录查询商品
- python网络爬虫获取景点信息源码
- python爬取维基百科程序语言消息盒(
- python新浪微博爬虫
- 12306爬虫实现
- 中国裁判文书网爬虫
- Python爬虫相关书籍.zip
评论
共有 条评论