def whitespace(options): # clean events Event.objects.filter(source="whitespace").delete() soup = BeautifulSoup(urlopen("http://www.0x20.be/Main_Page").read()) for event in soup.ul('li'): if event.text == 'More...': continue title = event.a.text url = "http://www.0x20.be" + event.a["href"] if "-" in event.b.text[:-1]: start, end = map(lambda x: parse(x.strip()), event.b.text[:-1].split("-")) else: start = parse(event.b.text[:-1]) end = None location = event('a')[1].text Event.objects.create( title=title, source="whitespace", url=url, start=start, end=end, location=location.strip() if location else None ) if not options["quiet"]: print "Adding %s [%s] (%s)..." % (title.encode("Utf-8"), "whitespace", location.encode("Utf-8"))
def whitespace(create_event): soup = BeautifulSoup(urlopen("http://www.0x20.be/Main_Page").read()) for event in soup.ul('li'): if event.text == 'More...': continue title = event.a.text url = "http://www.0x20.be" + event.a["href"] if "-" in event.b.text[:-1]: start, end = map(lambda x: parse(x.strip()), event.b.text[:-1].split("-")) else: start = parse(event.b.text[:-1]) end = None location = event('a')[1].text create_event(title=title, url=url, start=start, end=end, location=location.strip() if location else None)
def whitespace(create_event): soup = BeautifulSoup(urlopen("http://www.0x20.be/Main_Page").read()) for event in soup.ul('li'): if event.text == 'More...': continue title = event.a.text url = "http://www.0x20.be" + event.a["href"] if "-" in event.b.text[:-1]: start, end = map(lambda x: parse(x.strip()), event.b.text[:-1].split("-")) else: start = parse(event.b.text[:-1]) end = None location = event('a')[1].text create_event( title=title, url=url, start=start, end=end, location=location.strip() if location else None )
def whitespace(create_event): """ <p> <a href="/Whitespace" title="Whitespace">Whitespace</a> (0x20) is a <a href="/Documentation" title="Documentation">hackerspace</a> in the wonderful city of Ghent, Belgium. It is a physical space run by a group of people dedicated to various aspects of constructive & creative hacking. Our <a href="/FAQ" title="FAQ">FAQ</a> is an ever growing useful resource of information about who we are, what we do and how you can become a part of all the <b>awesomeness.</b> Also check out the hackerspaces in <a class="external text" href="http://we.voidwarranties.be">Antwerp</a>, <a class="external text" href="http://hackerspace.be/">Brussels</a> and <a class="external text" href="http://www.wolfplex.org/">Charleroi</a>. </p> """ soup = BeautifulSoup(requests.get("http://www.0x20.be/Main_Page").content) for event in soup.ul('li'): if event.text == 'More...': continue title = event.a.text url = "http://www.0x20.be" + event.a["href"] if "-" in event.b.text[:-1]: start, end = map(lambda x: parse(x.strip()), event.b.text[:-1].split("-")) else: start = parse(event.b.text[:-1]) end = None location = event('a')[1].text db_event = create_event( title=title, url=url, start=start, end=end, location=location.strip() if location else None ) db_event.tags.add("hackerspace")
def whitespace(): # clean events Event.objects.filter(source="whitespace").delete() soup = BeautifulSoup(urlopen("http://www.0x20.be/Main_Page").read()) for event in soup.ul('li'): title = event.a.text url = "http://www.0x20.be" + event.a["href"] start = parse(event.b.text[:-1]) location = event('a')[1].text Event.objects.create( title=title, source="whitespace", url=url, start=start, location=location, color="white", text_color="black", ) print "adding %s [%s] (%s)..." % (title.encode("Utf-8"), "whitespace", location.encode("Utf-8"))