68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
|
|
import os, sys
|
||
|
|
from datetime import datetime
|
||
|
|
from dateutil import relativedelta
|
||
|
|
|
||
|
|
sys.path.append('/var/www/digisnaxx.ado/scrapers')
|
||
|
|
import dtss
|
||
|
|
dtss.getReady()
|
||
|
|
|
||
|
|
from time import sleep
|
||
|
|
from pprint import pprint as ppr
|
||
|
|
import pytz
|
||
|
|
|
||
|
|
from events.models import Organization, Scraper, Calendar, Event
|
||
|
|
import events.digitools as digitools
|
||
|
|
|
||
|
|
tz_str = "-0800 UTC"
|
||
|
|
DATETIME_FORMAT = '%b %d, %Y %I:%M %p %z %Z'
|
||
|
|
DATETIME_FORMAT_2 = '%a, %b %d %Y %I %p %z %Z'
|
||
|
|
|
||
|
|
venue, created = Organization.objects.get_or_create(
|
||
|
|
name="Volcanic Theater",
|
||
|
|
city="Portland",
|
||
|
|
website="https://www.volcanictheatre.com/",
|
||
|
|
is_venue = True
|
||
|
|
)
|
||
|
|
|
||
|
|
scraper,item_count_start,virtcal = digitools.getScraper(venue, venue.website, 'pdx')
|
||
|
|
scraper.items = 0
|
||
|
|
scraper.save()
|
||
|
|
|
||
|
|
def get_events(ps, event_type):
|
||
|
|
contents = ps.xpath('.//*/div[@class="event-card"]')
|
||
|
|
for c in contents:
|
||
|
|
try:
|
||
|
|
event = {}
|
||
|
|
date = c.xpath('.//*/div[@class="date"]/text()')[0]
|
||
|
|
time = c.xpath('.//*/div[@class="doors-open"]/div/text()')[1]
|
||
|
|
event['date'] = (' ').join([date, time, tz_str])
|
||
|
|
event['scraper'] = scraper
|
||
|
|
event['calendars'] = [scraper.calendar]
|
||
|
|
event['title'] = c.xpath('.//div[@class="headline"]/text()')
|
||
|
|
try:
|
||
|
|
event['dateStamp'] = datetime.strptime(event['date'], DATETIME_FORMAT)
|
||
|
|
except Exception as e:
|
||
|
|
print(e)
|
||
|
|
pass
|
||
|
|
event['link'] = c.xpath('.//a/@href')
|
||
|
|
digitools.createBasicEvent(event, "Mu", venue)
|
||
|
|
scraper.items+=1
|
||
|
|
except Exception as e:
|
||
|
|
print("\nError: ", e)
|
||
|
|
pass
|
||
|
|
|
||
|
|
if len(sys.argv) >= 2:
|
||
|
|
arg1 = sys.argv[1]
|
||
|
|
br = digitools.getBrowser(arg1)
|
||
|
|
else:
|
||
|
|
print("No run_env")
|
||
|
|
br.close()
|
||
|
|
quit()
|
||
|
|
|
||
|
|
ps = digitools.getSource(br, venue.website)
|
||
|
|
get_events(ps, "Mu")
|
||
|
|
sleep(3)
|
||
|
|
|
||
|
|
digitools.updateScraper(scraper, item_count_start)
|
||
|
|
br.close()
|