spacepaste

  1.  
  2. def search_experiences():
  3. print('Experience Vaults')
  4. experiences = {}
  5. soup_text = []
  6. SEARCH_URL = "https://erowid.org/experiences/subs/exp_"
  7. substance = input('Search>').strip().lower()
  8. substance = substance[0].upper() + substance[1:]
  9. category = {'General':SEARCH_URL+substance+'_General.shtml','First Times':SEARCH_URL+substance+'_First_Times.shtml', 'Combonations':SEARCH_URL+substance+'_Combonations.shtml',\
  10. 'Retrospective/Summary':SEARCH_URL+substance+'_Retrospective_I_Summary.shtml', 'Preperation/Recipes':SEARCH_URL+substance+'_Preperation_I_Recipes.shtml',\
  11. 'Difficult Experiences':SEARCH_URL+substance+'_Difficult_Experiences.shtml', 'Bad Trips':SEARCH_URL+substance+'_Bad_Trips.shtml', 'Health Problems': SEARCH_URL+substance+'_Health_Problems.shtml',\
  12. 'Train Wrecks and Distaster Trips':SEARCH_URL+substance+'_Train_Wrecks_Trip_Disasters.shtml', 'Addiction and Habituation':SEARCH_URL+substance+'_Addiction_Habituation.shtml',\
  13. 'Glowing Experiences':SEARCH_URL+substance+'_Glowing_Experiences.shtml', 'Msytical Experiences':SEARCH_URL+substance+'_Mystical_Experiences.shtml', 'Health Benfits':SEARCH_URL+substance+'_Health_Benefits.shtml',\
  14. 'Families':SEARCH_URL+substance+'_Families.shtml', 'Medical Use':SEARCH_URL+substance+'_Medical_Use.shtml','What Was In That?':SEARCH_URL+substance+'_What_Was_in_That.shtml'}
  15. x=1
  16. for key in category:
  17. print('[+]',x,'.', key)
  18. x+=1
  19. cat = input('Category>').strip()
  20. if cat == 'exit:':
  21. sys.exit()
  22. if cat == "main":
  23. menu()
  24. #Grab page data -- value of key
  25. URL = (category[cat])
  26. data = requests.get(URL)
  27. content = data.text
  28. search_soup = BeautifulSoup(content, 'html.parser')
  29. x = 0
  30. for link in search_soup.find_all('a'):
  31. print('[+]',x, link.text)
  32. experiences[x] = link.get('href')
  33. x += 1
  34. choice = input('Choice>').strip()
  35. data = requests.get('https://erowid.org'+ str(experiences[int(choice)]))
  36. content = data.text
  37. search_soup = BeautifulSoup(content, 'html.parser')
  38. #for comment in search_soup.find_all(string=lambda text:isinstance(text,Comment)):
  39. # print(comment)
  40. soup_text.append(str(search_soup))
  41. #experience = str(re.search(r"<!-- Start Body -->(.*)<!-- End Body -->",str(soup_text[0])))
  42. for index in soup_text:
  43. print(soup_text)
  44. experience = re.search('<!-- Start Body -->(.*)<!-- End Body -->', soup_text[0])
  45. print(experience)
  46.