爬虫 - POJ题目信息
####方便Markdown写博客
import re,requests
from bs4 import BeautifulSoup# ptt = soup.find_all(name='div', attrs={"class":"ptt"})[0]
#获取小标题
def get_title(soup):return soup.find_all(name='p', attrs={"class":"pst"})
#获取文本
def get_text(soup):return soup.find_all(name='div', attrs={"class":"ptx"})
#获取样例
def get_sample(soup):return soup.find_all(name='pre', attrs={"class":"sio"})print("Please input URL:")
url = input()
html = requests.get(url)
soup = BeautifulSoup(html.text, "lxml")text_list = get_text(soup)[0:3]
title_list = get_title(soup)[0:5]
sample_list = get_sample(soup)text = list()
title = list()
all = list()
#处理文本 加换行符
for i in text_list:text.append(i.text + '\r\n')
for i in title_list:title.append("#### " + i.text + '\r\n')
for i in sample_list:i = '```\r\n' + i.string + '\r\n' + '```\r\n'text.append(i)for i in range(5):all.append(title[i] + text[i])
URL = '[题目链接]' + '(' + url + ')' + '\r\n'
f = open('POJ.txt', 'w')
f.write(URL)
for i in all:f.write(i)
f.write("#### AC\n- ")
f.close()
print("Done!")
爬虫 - POJ题目信息相关推荐
- 爬虫 - HDU题目信息
方便Markdown写博客 import re, requests from bs4 import BeautifulSoup#获取小标题 def get_title(soup):return sou ...
- 爬虫爬取信息(python))
先来爬点简单的,然后再爬其他的东西 文章目录 1,实验工具 2,爬取网站 1,先打开要爬的学校网站 2,代码 3,爬取学校官网的信息通知 1,查看网站 2,代码 4,总结 5,参考 1,实验工具 an ...
- Python 网络爬虫笔记4 -- 信息标记与提取
Python 网络爬虫笔记4 – 信息标记与提取 Python 网络爬虫系列笔记是笔者在学习嵩天老师的<Python网络爬虫与信息提取>课程及笔者实践网络爬虫的笔记. 课程链接:Pytho ...
- 检测到目标url存在内部ip地址泄露_Cendertron,动态爬虫与敏感信息泄露检测
Cendertron,动态爬虫与敏感信息泄露检测 Cendertron = Crawler + Rendertron Cendertron https://url.wx-coder.cn/HinPM ...
- python——爬虫实现网页信息抓取
首先实现关于网页解析.读取等操作我们要用到以下几个模块 import urllib import urllib2 import re 我们可以尝试一下用readline方法读某个网站,比如说百度 de ...
- python爬虫找工作怎么找_python爬虫判断招聘信息是否存在的实例代码
在找工作的时候,我们会选择上网查询招聘的信息,或者是通过一些招聘会进行现场面试.但由于信息更新不及时,有一些岗位会出现下架的情况,如果我们不注意的话,可能就扑了空.在时间上耽误了不说,面试的信息也会受 ...
- 四小时学python爬虫爬取信息系列(第一天)
四小时学python爬虫爬取信息系列(第一天)(全是干货) 1.安装requests库(可以在电脑python,我是进入anaconda我建的虚拟环境) anaconda虚拟环境法流程: conda ...
- 最没灵魂的爬虫——Selenium 游戏信息的爬取与分析
最没有灵魂的爬虫--Selenium 游戏信息爬取与分析 准备工作 IDE选取 selenium安装 ChromeDriver安装与配置 还需要用到的其他python库 数据爬取 杉果游戏的数据获取 ...
- Python 爬虫 中国行政区划信息爬取 (初学者)
Python 爬虫 中国行政区划信息爬取 (初学者) 背景 环境准备 代码片段 1.定义地址信息对象 2.地址解析对象 2.1 获取web信息 2.2 web信息解析 2.3 区划信息提取 2.4 省 ...
最新文章
- Mysql 批量插入数据的方法
- Ipython 和 python 的区别
- sqlserver数据库迁移mysql_在项目中迁移MS SQLServer到Mysql数据库,实现MySQL数据库的快速整合...
- Tyvj 1921 Freda的烦恼
- sql 数字转换为16进制数函数
- PHP运行模式的深入理解
- comsol软件_COMSOL软件 5.4 版本新增“薛定谔-泊松方程“多物理场接口
- k3 lede刷官改_斐讯K3路由LEDE固件刷回官方原版固件
- iOS客户端安装包大小优化
- 项目工作说明书(SOW)
- arduino蓝牙主从机通讯
- 手写简易版spring MVC框架
- 杜撰的柏拉图(转自李止介的个人空间)
- MyGUI_Orge官网教程_5.窗口部件控制
- icon php图标集合,iconfont字体图标和各种css小图标的详解
- 滴滴出行2016校招编程题
- JavaScript-修炼之路第五层
- SpringBoot单元测试断言 assertions
- java新应用_java8新特性的实际应用
- windows 下 MAC地址绑定