个人作业——CVPR顶会论文爬取
main.py
#保存单个界面数据
def getInfo(url):
# url='https://openaccess.thecvf.com/WACV2021'
header={
'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Mobile Safari/537.36'
}
html=requests.get(url=url,headers=header).text
soup=BeautifulSoup(html,'lxml')
dl=soup.find('dl')
print(dl.find('dt'))
info=dl.find_all(class_='bibref pre-white-space')
for i in info:
print('----------------------------------------------------------------------------------------------------------')
print(i.text)
# info0=i.find(class_='bibref pre-white-space').get_text()
# print(info0)
#处理数据
info1=i.text.strip('@InProceedings{,}')
info2=info1.replace('=','')
info2=info2.replace("'","''")
info2=info2.replace('{','')
info2=info2.replace('}',',')
info2=info2.replace('author',',')
info2=info2.replace('title','')
info2=info2.replace('book','')
info2=info2.replace('month','')
info2=info2.replace('year','')
info2=info2.replace('pages','')
# info2=info2.replace(' ','')
info2=info2.replace('\n','')
info2=info2.replace(' ','')
info2=",,"+info2+","
print(info2)
info3=info2.split(',,')
print(info3) #保存数据
list=[]
for i in info3:
list.append(i.strip(' '))
print(i.strip(' '))
print(str(list[1]))
#链接数据库
conn=pymysql.connect(host='39.106.103.180',port=3306,user='root',password='E6B3628525e4',database='user')
cursor=conn.cursor()
sql_select="select * from paper where title='"+str(list[3])+"'"
if(cursor.execute(sql_select)!=1):
sql="insert into paper(author,title,booktitle,month,year,pages) values('"+str(list[2])+"','"+str(list[3])+"','"+str(list[4])+"','"+str(list[5])+"','"+str(list[6])+"','"+str(list[7])+"')"
a=cursor.execute(sql)
re=cursor.fetchall()
print(re)
conn.commit()
cursor.close()
conn.close() url='https://openaccess.thecvf.com/menu'
headers={
'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Mobile Safari/537.36'
}
html=requests.get(url=url,headers=headers).text
print(html)
soup=BeautifulSoup(html,'lxml')
dds=soup.find_all('dd')
# print('________________________________________________________________________________________________________________')
# print(dds)
for dd in dds:
print('----------------------------------------------------------------------------------------------------------------------')
# print(dd.text) #标题
for d in dd.find_all('a'):
# print(d.text) #会议性质
# print(d['href'],'\n') #地址 url_MainConference=url.strip('menu')+str(d['href']).strip('/')
print(url_MainConference.strip('.py'))
# menu=requests.get(url=url_MainConference,headers=headers).text
getInfo(url_MainConference.strip('.py '))
注意数据库字段设置合适的长度
个人作业——CVPR顶会论文爬取的更多相关文章
- CVPR顶会论文爬取存入MySQL数据库(标题、摘要、作者、PDF链接和原地址)
main.py import pymysql import re import requests # 连接数据库函数 from bs4 import BeautifulSoup def insertC ...
- 论文爬取 & 词频统计2.0
一.Github地址 课程项目要求 队友博客 二.具体分工 031602225 林煌伟 :负责C++部分主要功能函数的编写,算法的设计以及改进优化 031602230 卢恺翔 : 爬虫 ...
- 个人作业2-6.4-Python爬取顶会信息
1.个人作业2 数据爬取阶段 import requestsfrom lxml import etreeimport pymysqldef getdata(url): # 请求CVPR主页 page_ ...
- 交作业啊,python爬取58的页面
第一次写博文,好紧张啊,写这么烂怎么给别人看啊先做下总结: 刚开始学习python,自我感觉python写起来确实很方便,各种库,各种语法糖,不过刚接触,一下子记不下来这么多东西,总感觉乱乱的,用的多 ...
- 爬取CVPR 2018过程中遇到的坑
爬取 CVPR 2018 过程中遇到的坑 使用语言及模块 语言: Python 3.6.6 模块: re requests lxml bs4 过程 一开始都挺顺利的,先获取到所有文章的链接再逐个爬取获 ...
- Python 爬取外文期刊论文信息(机械 仪表工业)
NSTL国家科技图书文献中心 2017 机械 仪表工业 所有期刊论文信息 代码比较随意,不要介意 第一步,爬取所有期刊链接 #coding=utf-8 import time from se ...
- python爬取中国知网部分论文信息
爬取指定主题的论文,并以相关度排序. #!/usr/bin/python3 # -*- coding: utf-8 -*- import requests import linecache impor ...
- Python爬取CSDN博客文章
0 url :http://blog.csdn.net/youyou1543724847/article/details/52818339Redis一点基础的东西目录 1.基础底层数据结构 2.win ...
- 将爬取的实习僧网站数据传入HDFS
一.引言: 作为一名大三的学生,找实习对于我们而言是迫在眉睫的.实习作为迈入工作的第一步,它的重要性不言而喻,一份好的实习很大程度上决定了我们以后的职业规划. 那么,一份好的实习应该考量哪些因素呢? ...
随机推荐
- OOP面向对象程序设计原则
OOP面向对象程序设计原则 开闭原则(Open Close Principle) 对扩展开放,对修改关闭 里氏代换原则(Liskov Substitution Principle) 继承必须确保超累所 ...
- Check Directory Existence in Shell
The following command in one line can check if a directory exists. You can check the return value (& ...
- 用AutoHotkey做汉字到Unicode字符串的转换
要把汉字转换为搜的形式,也就是在汉字的Unicode Big Endian编码前面加"&#x",后面加分号.例如""字转换后为"搜" ...
- SpringBoot开发十八-显示评论
需求介绍 显示评论,还是我们之前做的流程. 数据层:根据实体查询一页的评论数据,以及根据实体查询评论的数量 业务层:处理查询评论的业务,处理查询评论数量的业务 表现层:同时显示帖子详情数据时显示该帖子 ...
- mock平台介绍和moco的简单例子
1.mock是什么?mock测试就是在测试过程中,对于某些不容易构造或者不容易获取的对象,用一个虚拟的对象来创建以便测试的测试方法.在具体的测试过程中,我们经常会碰到需要模拟数据或者接口的情况,因为环 ...
- filebeat+ELK配置及常用操作
背景介绍 最近工作涉及几台新服务器的日志需要接入ELK系统,配置思路如下: 使用Filebeat收集本地日志数据,Filebeat监视日志目录或特定的日志文件,再发送到消息队列到kafka,然后log ...
- SQL 练习33
查询课程编号为 01 且课程成绩在 80 分以上的学生的学号和姓名 SELECT Student.SId,Student.Sname,Cname,score from Student,Course,S ...
- React性能优化总结
本文主要对在React应用中可以采用的一些性能优化方式做一下总结整理 前言 目的 目前在工作中,大量的项目都是使用react来进行开展的,了解掌握下react的性能优化对项目的体验和可维护性都有很大的 ...
- COM笔记-COM库函数
COM在OLE32.DLL和 OLE32.LIB定义了一些常用的函数.在使用这些函数前要先调用CoInitialize来初始化COM库.当进程不再需要使用COM库函数时要调用CoUninitializ ...
- WPF---依赖属性(二)
一.概要 我们将会通过一个简单的综合例子来阐述下依赖属性的变化. 场景:我们在一个文本框中输入一个数字,然后对应的panel中会出现对应的椭圆,椭圆的个数与输入的文本相同. 我们在MainWindow ...