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顶会论文爬取的更多相关文章

  1. CVPR顶会论文爬取存入MySQL数据库(标题、摘要、作者、PDF链接和原地址)

    main.py import pymysql import re import requests # 连接数据库函数 from bs4 import BeautifulSoup def insertC ...

  2. 论文爬取 & 词频统计2.0

    一.Github地址      课程项目要求    队友博客 二.具体分工 031602225 林煌伟 :负责C++部分主要功能函数的编写,算法的设计以及改进优化 031602230 卢恺翔 : 爬虫 ...

  3. 个人作业2-6.4-Python爬取顶会信息

    1.个人作业2 数据爬取阶段 import requestsfrom lxml import etreeimport pymysqldef getdata(url): # 请求CVPR主页 page_ ...

  4. 交作业啊,python爬取58的页面

    第一次写博文,好紧张啊,写这么烂怎么给别人看啊先做下总结: 刚开始学习python,自我感觉python写起来确实很方便,各种库,各种语法糖,不过刚接触,一下子记不下来这么多东西,总感觉乱乱的,用的多 ...

  5. 爬取CVPR 2018过程中遇到的坑

    爬取 CVPR 2018 过程中遇到的坑 使用语言及模块 语言: Python 3.6.6 模块: re requests lxml bs4 过程 一开始都挺顺利的,先获取到所有文章的链接再逐个爬取获 ...

  6. Python 爬取外文期刊论文信息(机械 仪表工业)

    NSTL国家科技图书文献中心    2017  机械 仪表工业  所有期刊论文信息 代码比较随意,不要介意 第一步,爬取所有期刊链接 #coding=utf-8 import time from se ...

  7. python爬取中国知网部分论文信息

    爬取指定主题的论文,并以相关度排序. #!/usr/bin/python3 # -*- coding: utf-8 -*- import requests import linecache impor ...

  8. Python爬取CSDN博客文章

    0 url :http://blog.csdn.net/youyou1543724847/article/details/52818339Redis一点基础的东西目录 1.基础底层数据结构 2.win ...

  9. 将爬取的实习僧网站数据传入HDFS

     一.引言: 作为一名大三的学生,找实习对于我们而言是迫在眉睫的.实习作为迈入工作的第一步,它的重要性不言而喻,一份好的实习很大程度上决定了我们以后的职业规划. 那么,一份好的实习应该考量哪些因素呢? ...

随机推荐

  1. Use Emacs as Personal Knowledge Base

    http://stackoverflow.com/questions/2014636/how-to-maintain-an-emacs-based-knowledge-base

  2. arraycopy将数组分为两部分时游标的设置方法

    System.arraycopy是复制数组的一个常用工具,它在游标处如何分为两个是一个需要注意的问题,例如下面的示例代码: byte [] src = { 104, 101, 108, 108, 11 ...

  3. JVM内存调整

    JVM内存调整 先试着调整一下idea的 找到软件安装位置/bin/idea64.exe.vmoptions 给他直接整个起飞的,改成 -Xms512m -Xmx1500m 找到Java安装的位置/j ...

  4. Pikachu-CSRF模块

    一.概述 Cross-site request forgery 简称为"CSRF",在CSRF的攻击场景中攻击者会伪造一个请求(这个请求一般是一个链接),然后欺骗目标用户进行点击, ...

  5. SQL 练习7

    查询所有同学的学生编号.学生姓名.选课总数.所有课程的总成绩(没成绩的显示为 null ) SELECT Student.SId,sname,t.选课总数,t.总成绩 from Student LEF ...

  6. 虚拟机下安装Centos设置静态ip,并通过桥接连接

    Centos7.6设置静态IP 1.CentOS7默认网卡设备文件存放于该目录下 /etc/sysconfig/network-scripts/ 网卡设备默认的名字为:ifcfg-ens33 查看网卡 ...

  7. 带你读AI论文丨LaneNet基于实体分割的端到端车道线检测

    摘要:LaneNet是一种端到端的车道线检测方法,包含 LanNet + H-Net 两个网络模型. 本文分享自华为云社区<[论文解读]LaneNet基于实体分割的端到端车道线检测>,作者 ...

  8. css生成彩色阴影

    通常用css生成单色或者同色系的的阴影(box-shadow),其实可以通过巧妙的利用 filter: blur 模糊滤镜,可以生成渐变色或者说是颜色丰富的阴影效果,如图: 原理: 利用伪元素,生成一 ...

  9. WPF LiveChart 图表详解

    //参考网址:https://www.cnblogs.com/zh7791/p/12617961.html 本文主要介绍LiveChart.WPF 中的图表的使用方法 类: 数据绑定, 数据显示样式等 ...

  10. asp.net core 常见知识点