リンクhttp://dl.acm.org/results.cfm?CFID=376026650&CFTOKEN=88529867の html ファイルから情報を引き出そうとしています。すべての論文のタイトルについて、著者、ジャーナル名、およびアブストラクトが必要です。しかし、私はそれらをまとめる前に、それぞれの最初の反復バージョンを取得しています。助けてください。つまり、最初にタイトルのリストを取得し、次に著者、次に雑誌、次に要約を取得し、次にタイトルごとに、最初にタイトル、次にそれぞれの著者、雑誌名、および要約を取得します。個別ではなく、まとめて必要です。
from BeautifulSoup import BeautifulSoup
from bs4 import BeautifulSoup
import urllib2
import requests
import re
f = open('acmpage.html', 'r') #open html file stores locally
html = f.read() #read from the html file and store the content in 'html'
soup = BeautifulSoup(html)
pret = soup.prettify()
soup1 = BeautifulSoup(pret)
for content in soup1.find_all("table"):
soup2 = BeautifulSoup(str(content))
pret2 = soup2.prettify()
soup3 = BeautifulSoup(pret2)
for titles in soup3.find_all('a', target = '_self'): #to print title
print "Title: ",
print titles.get_text()
for auth in soup3.find_all('div', class_ = 'authors'): #to print authors
print "Authors: ",
print auth.get_text()
for journ in soup3.find_all('div', class_ = 'addinfo'): #to print name of journal
print "Journal: ",
print journ.get_text()
for abs in soup3.find_all('div', class_ = 'abstract2'): # to print abstract
print "Abstract: ",
print abs.get_text()