Skip to content

Instantly share code, notes, and snippets.



Last active Jan 24, 2018
What would you like to do?
import requests
from BeautifulSoup import BeautifulSoup
import csv
visit = {"2017": "", "2018": ""}
myFile = open('CONFERENCES.csv', 'w')
with myFile:
writer = csv.writer(myFile)
for year in visit:
r = requests.get(visit[year])
soup = BeautifulSoup(r.text)
ul = soup.findAll("ul", {"class":"list"})[0]
for li in ul.findAll('li'):
name = li.find("span", {"class": "name"})
if name:
address = li.find("span", {"itemprop": "address"})
location = address.find("span", {"itemprop": "addressLocality"})
region = address.find("span", {"itemprop": "addressRegion"})
country = address.find("span", {"itemprop": "addressCountry"})
date = li.find("span", {"itemprop": "startDate"})
if country and date:
writer.writerows([[year, (name.text).encode('utf-8').strip(), country.text, date["content"]]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment