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 '))

注意数据库字段设置合适的长度

最新文章

  1. POJ1743 Musical Theme [后缀数组]
  2. 初识 Burp Suite
  3. 新版react踩坑总结
  4. Git-仓库基本结构
  5. String的两个API,判断指定字符串是否包含另一字符串,在字符串中删除指定字符串。
  6. JS代码片段:appendHTML 和 insertAdjacentHTML
  7. Spring---Web MVC关于前台传值转换问题
  8. PHP简单获取数据库查询结果并返回JSON
  9. HDU_2022——海选女主角
  10. Android网络请求框架AsyncHttpClient实例详解(配合JSON解析调用接口)
  11. Spark_总结七_troubleshooting
  12. 关于在Django中Json无法序列化datetime的解决办法
  13. TestNG 自动化测试入门教程--典型示例
  14. aizhan爱站关键字采集
  15. Unable to preventDefault inside passive event listener
  16. SpringSecurity初步理解
  17. 使用Excel批量给数据添加单引号和逗号
  18. Python学习 day04打卡
  19. php并发
  20. Django models 的常用字段类型和字段参数

热门文章

  1. [JAVA]关于excel的jxl包的操作-创建sheet
  2. Ubuntu上安装gevent
  3. 长亭xray被动扫描
  4. 【翻译稿】Behavior Driven Development (BDD)行为驱动开发
  5. 微信小程序自定义顶部
  6. 小程序iphone蒙层滚动穿透
  7. 简单实现 nodejs koa2 mysql 增删改查 制作接口
  8. com 组件的本知识
  9. .Net Core WebApi(二)
  10. JavaWeb之分页查询