LoginSignup
0
0

More than 1 year has passed since last update.

論文集のタイトル一覧スプレッシートを作りたかったのでスクレイピング

Last updated at Posted at 2019-06-08

論文のタイトル一覧が欲しかった

IEEEとかの学会にでると、論文集がもらえます。
その論文集のタイトル一覧とがあればいいなーと思ったのでスクレイピングしました。

実行環境

次に実行環境を示します。

Soft and Hard バージョン
Windowds 10 Pro 17763.316 build
python 2. 7

code

ライブラリは、beautifulSoupを使用しました


#!/usr/bin/env python
# -*- coding: utf-8 -*-

from bs4 import BeautifulSoup as bf
import csv

def getHtml(file_name):
  file = open(str(file_name))
  html = bf(file,'lxml')
  file.close

  return html

def getTitle(html, cvlist):

 for t in html.find_all("", class_="pTtl"):
  csvlist = []
  text=t.get_text()
  text = text.encode('utf-8')
  csvlist.append(text)
  writecsv.writerow(csvlist)

if __name__ == "__main__":

   html = getHtml('index.html')
   f = open("output.csv", "w")
   writecsv = csv.writer(f)
   f.close()

まとめ

今後も使うと思うので、もっと使いやすいように改良していきたいと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0