mirror of
https://github.com/OpenJarbas/PySychonaut.git
synced 2025-02-19 15:00:39 +01:00
SEARCH
This commit is contained in:
parent
d4a9e03bac
commit
df14f2625e
14
example.py
14
example.py
@ -47,4 +47,18 @@ effects : Psychedelic
|
||||
chem_name : d-lysergic acid diethylamide
|
||||
description : LSD is the best known and most researched psychedelic. It is the standard against which all other psychedelics are compared. It is active at extremely low doses and is most commonly available on blotter or in liquid form.
|
||||
|
||||
"""
|
||||
|
||||
reports = Erowid.search_reports("1P-LSD")
|
||||
print reports[0].keys()
|
||||
for report in reports[:5]:
|
||||
print report["substance"], report["url"], report["date"]
|
||||
|
||||
"""
|
||||
['date', 'url', 'substance', 'name', 'author']
|
||||
1P-ETH-LAD https://erowid.org/experiences/exp.php?ID=109647 Dec 9 2016
|
||||
1P-LSD https://erowid.org/experiences/exp.php?ID=108914 Aug 1 2016
|
||||
1P-LSD https://erowid.org/experiences/exp.php?ID=108138 Mar 16 2016
|
||||
1P-LSD https://erowid.org/experiences/exp.php?ID=108063 Mar 11 2016
|
||||
1P-LSD https://erowid.org/experiences/exp.php?ID=107880 Feb 3 2016
|
||||
"""
|
@ -158,5 +158,40 @@ class Erowid(object):
|
||||
exp = Erowid.get_experience(random.randint(1, 111451))
|
||||
return exp
|
||||
|
||||
@staticmethod
|
||||
def search_reports(search_term, order="substance"):
|
||||
base_url = "https://erowid.org/experiences/"
|
||||
search_term = search_term.replace(" ", "+")
|
||||
url = base_url + "exp.cgi?Str=" + search_term
|
||||
if order == "substance":
|
||||
url += "&OldSort=SA"
|
||||
elif order in ["date", "recent"]:
|
||||
url += "&OldSort=PDD"
|
||||
elif order in ["old", "older", "oldest"]:
|
||||
url += "&OldSort=PDA"
|
||||
elif order in ["rating"]:
|
||||
url += "&OldSort=RA"
|
||||
elif order is not None:
|
||||
url += "&OldSort=" + order
|
||||
|
||||
response = requests.get(url).text
|
||||
soup = BeautifulSoup(response, "lxml")
|
||||
table = soup.find('table', {'class': "exp-list-table"})
|
||||
table = table.find_all("tr", {'class': ""})[2:]
|
||||
reports = []
|
||||
for r in table:
|
||||
report = {}
|
||||
fields = r.find_all("td")[1:]
|
||||
report["name"] = fields[0].getText()
|
||||
report["author"] = fields[1].getText()
|
||||
report["substance"] = fields[2].getText()
|
||||
report["date"] = fields[3].getText()
|
||||
report["url"] = base_url + r.find("a")["href"]
|
||||
reports.append(report)
|
||||
return reports
|
||||
|
||||
|
||||
reports = Erowid.search_reports("1P-LSD")
|
||||
print reports[0].keys()
|
||||
for report in reports[:5]:
|
||||
print report["substance"], report["url"], report["date"]
|
41
readme.md
41
readme.md
@ -14,18 +14,24 @@ or
|
||||
|
||||
## usage
|
||||
|
||||
importing
|
||||
|
||||
from pyerowid import Erowid
|
||||
|
||||
getting experience reportS
|
||||
|
||||
|
||||
trip_report = Erowid.random_experience()
|
||||
print trip_report.keys()
|
||||
|
||||
""" ['url', 'gender', 'age', 'experience', 'drug', 'year', 'date', 'exp_id', 'dosage'] """
|
||||
|
||||
trip_report = Erowid.get_experience(1)
|
||||
for key in trip_report:
|
||||
print key, ":", trip_report[key]
|
||||
|
||||
"""
|
||||
output
|
||||
|
||||
['url', 'gender', 'age', 'experience', 'drug', 'year', 'date', 'exp_id', 'dosage']
|
||||
|
||||
url : https://erowid.org/experiences/exp.php?ID=1
|
||||
gender : not specified
|
||||
age : not given
|
||||
@ -36,24 +42,42 @@ or
|
||||
exp_id : 1
|
||||
dosage : [{'substance': u'mdma', 'form': u'(pill / tablet)', 'method': u'oral', 'ammount': u'0.5 tablets', 'time': u't+ 0:00'}, {'substance': u'mdma', 'form': u'(pill / tablet)', 'method': u'oral', 'ammount': u'0.5 tablets', 'time': u't+ 0:45'}]
|
||||
|
||||
"""
|
||||
searching experience reports
|
||||
|
||||
reports = Erowid.search_reports("1P-LSD")
|
||||
print reports[0].keys()
|
||||
for report in reports[:5]:
|
||||
print report["substance"], report["url"], report["date"]
|
||||
|
||||
output
|
||||
|
||||
['date', 'url', 'substance', 'name', 'author']
|
||||
1P-ETH-LAD https://erowid.org/experiences/exp.php?ID=109647 Dec 9 2016
|
||||
1P-LSD https://erowid.org/experiences/exp.php?ID=108914 Aug 1 2016
|
||||
1P-LSD https://erowid.org/experiences/exp.php?ID=108138 Mar 16 2016
|
||||
1P-LSD https://erowid.org/experiences/exp.php?ID=108063 Mar 11 2016
|
||||
1P-LSD https://erowid.org/experiences/exp.php?ID=107880 Feb 3 2016
|
||||
|
||||
get_X (chemicals, pharms, herbs, animals, plants. smarts)
|
||||
|
||||
chemicals = Erowid.get_chemicals()
|
||||
print chemicals[0].keys()
|
||||
names = [c["name"] for c in chemicals]
|
||||
print names
|
||||
|
||||
"""
|
||||
output
|
||||
|
||||
['url', 'other_names', 'name', 'effects']
|
||||
[u'absinthe', u'acetylfentanyl', u'adrenochrome', u'aet', u'alcohol', u'alpha-pvp', u'amitriptyline', u'amphetamine', u'amt', u'ayahuasca', u'barbiturates', u'bk-mbdb', u'bromo-dragonfly', u'bufotenin', u'bz', u'bzp', u'caffeine', u'cannabinoids', u'capsaicin', u'carbogen', u'cathinone', u'chloroform', u'chocolate', u'cocaine / crack', u'desomorphine', u'det', u'dipt', u'dmt', u'dob', u'doc', u'doi', u'dom', u'dpt', u'dxm', u'ephedrine', u'ether', u'ethylcathinone', u'ethylene', u'ethylphenidate', u'ghb', u'ghv', u'harmala', u'heroin', u'hypocretin', u'iap', u'ibogaine', u'inhalants', u'ketamine', u'lsa', u'lsd', u'lsz', u'maois', u'mbdb', u'mcpp', u'mda', u'mde', u'mdai', u'mdma', u'mdpr', u'mdpv', u'mescaline', u'met', u'methadone', u'methamphetamines', u'methaqualone', u'methiopropamine', u'methoxetamine', u'methoxphenidine', u'methylone', u'mipt', u'mptp', u'nbome', u'nicotine', u'nitrous', u'opiates', u'opium', u'petroleum ether', u'piperazines', u'pcp', u'pma', u'pmma', u'psilocybin & psilocin', u'salvinorin b ethoxymethyl ether', u'scopolamine', u'"spice" product', u'ssris', u'tfmpp', u'thc', u'tma-2', u'toad venom', u'1,4-butanediol', u'2-aminoindan', u'2c-b', u'2c-b-fly', u'2c-c', u'2c-c-nbome', u'2c-d', u'2c-e', u'2c-i', u'2c-i-nbome', u'2c-p', u'2c-t-2', u'2c-t-4', u'2c-t-7', u'2c-t-21', u'3c-p', u'3-meo-pcp', u'4-acetoxy-det', u'4-acetoxy-dipt', u'4-acetoxy-dmt', u'4-acetoxy-mipt', u'4-fluoroamphetamine', u'4-fluoromethcathinone', u'4-hydroxy-dipt', u'4-hydroxy-met', u'4-hydroxy-mipt', u'4-hydroxy-mpt', u'4-meo-pcp', u'4-methylaminorex', u'4-methylmethcathinone', u'4-methylethcathinone', u'4-mta', u'5-it', u'5-meo-amt', u'5-meo-dalt', u'5-meo-dmt', u'5-meo-dipt', u'5-meo-mipt', u'6-apb', u'other chemicals']
|
||||
|
||||
"""
|
||||
parsing a substance page
|
||||
|
||||
chem_data = Erowid.parse_page("https://erowid.org/chemicals/lsd/lsd.shtml")
|
||||
for key in chem_data:
|
||||
print key, ":", chem_data[key]
|
||||
|
||||
"""
|
||||
output
|
||||
|
||||
info : {'basics': 'https://erowid.org/chemicals/lsd/lsd_basics.shtml', 'dose': 'https://erowid.org/chemicals/lsd/lsd_dose.shtml', 'health': 'https://erowid.org/chemicals/lsd/lsd_health.shtml', 'effects': 'https://erowid.org/chemicals/lsd/lsd_effects.shtml', 'images': 'https://erowid.org/chemicals/lsd/lsd_images.shtml', 'law': 'https://erowid.org/chemicals/lsd/lsd_law.shtml', 'chemistry': 'https://erowid.org/chemicals/lsd/lsd_chemistry.shtml'}
|
||||
picture : https://erowid.org/chemicals/lsd/images/lsd_summary1.jpg
|
||||
name : lsd-25
|
||||
@ -63,4 +87,5 @@ or
|
||||
chem_name : d-lysergic acid diethylamide
|
||||
description : LSD is the best known and most researched psychedelic. It is the standard against which all other psychedelics are compared. It is active at extremely low doses and is most commonly available on blotter or in liquid form.
|
||||
|
||||
"""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user