Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
PrimeObsession.py
# -*- coding: utf-8 -*-
import requests
import lxml
import sympy
import numpy
def PeopleSetDetail(PeopleSetID, PrimeObsession=False):
site = 'http://comics.www.collectors-society.com/'
url = 'registry/comics/PeopleSetDetail.aspx?PeopleSetID=%s' % PeopleSetID
req = requests.get(site + url)
html = lxml.etree.HTML(req.text)
rows = html.xpath("//table[@class='TopSetsGrid']/tr")
data = list()
for row in rows:
cols = row.xpath("td/a/text()")
try:
if sympy.isprime(cols[1]) or not PrimeObsession:
data.append(cols[-2::-1])
except (IndexError, ValueError):
pass
return numpy.array(data)
print PeopleSetDetail(79399, PrimeObsession=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment