scraper.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import requests
  2. import re
  3. import html
  4. def scrape(url):
  5. data = requests.get(url).text
  6. find = re.findall(f'<p><a href="(.*?)" class="btn btn-default"', data)
  7. links = []
  8. for link in find:
  9. link = link
  10. links.append(f'https://pokeflix.tv{link}')
  11. find = re.findall(f'<h4>(.*?)</h4>', data)
  12. names = []
  13. for name in find:
  14. names.append(html.unescape(name))
  15. find = re.findall(f'<img src="(.*?)" alt="thumbnail" />', data)
  16. images = []
  17. for image in find:
  18. images.append(f'https://pokeflix.tv{image}')
  19. dict = [
  20. {'name': names, 'links': links, "images": images}
  21. for names, links, images in zip(names, links, images)
  22. ]
  23. return dict
  24. def get_episodes(link):
  25. return scrape(link)
  26. def get_seasons():
  27. return scrape("https://pokeflix.tv")
  28. def get_movies():
  29. return scrape("https://pokeflix.tv/movies/")
  30. def get_specials():
  31. return scrape("https://pokeflix.tv/specials/")
  32. #print(get_episodes("https://www.pokeflix.tv/browse/pokemon-indigo-league"))
  33. #def get_seasons():
  34. data = [
  35. {"gen": "Generation 1 (Kanto Region & Orange Islands)",
  36. "seasons": [
  37. {"name": "Orange Island Adventures",
  38. "link": "https://pokeflix.tv/browse/pokemon-orange-island-adventures"},
  39. {"name": "Indigo League",
  40. "link": "https://pokeflix.tv/browse/pokemon-indigo-league"},
  41. ],
  42. },
  43. {"gen": "Generation 2 (Johto Region)",
  44. "seasons": [
  45. {"name": "Master Quest",
  46. "link": "https://pokeflix.tv/browse/pokemon-master-quest"},
  47. {"name": "Johto League Champions",
  48. "link": "https://pokeflix.tv/browse/pokemon-johto-league-champions"},
  49. {"name": "The Johto Journeys",
  50. "link": "https://pokeflix.tv/browse/pokemon-the-johto-journeys"},
  51. ],
  52. },
  53. {"gen": "Generation 3 (Hoenn Region)",
  54. "seasons": [
  55. {"name": "Battle Frontier",
  56. "link": "https://pokeflix.tv/browse/pokemon-battle-frontier"},
  57. {"name": "Advanced Battle",
  58. "link": "https://pokeflix.tv/browse/pokemon-advanced-battle"},
  59. {"name": "Advanced Challenge",
  60. "link": "https://pokeflix.tv/browse/pokemon-advanced"},
  61. ],
  62. },
  63. {"gen": "Generation 4 (Sinnoh Region)",
  64. "seasons": [
  65. {"name": "DP Sinnoh League Victors",
  66. "link": "https://pokeflix.tv/browse/pokemon-dp-sinnoh-league-victors"},
  67. {"name": "DP Galactic Battles",
  68. "link": "https://pokeflix.tv/browse/pokemon-dp-galactic-battles"},
  69. {"name": "DP Battle Dimension",
  70. "link": "https://pokeflix.tv/browse/pokemon-dp-battle-dimension"},
  71. {"name": "Diamond and Pearl",
  72. "link": "https://pokeflix.tv/browse/pokemon-diamond-and-pearl"},
  73. ],
  74. },
  75. {"gen": "Generation 5 (Unova Region)",
  76. "seasons": [
  77. {"name": "BW Adventures in Unova",
  78. "link": "https://pokeflix.tv/browse/pokemon-bw-adventures-in-unova"},
  79. {"name": "BW Rival Destinies",
  80. "link": "https://pokeflix.tv/browse/pokemon-bw-rival-destinies"},
  81. {"name": "Black & White",
  82. "link": "https://pokeflix.tv/browse/pokemon-black-and-white"},
  83. ],
  84. },
  85. {"gen": "Generation 6 (Kalos Region)",
  86. "seasons": [
  87. {"name": "XYZ",
  88. "link": "https://pokeflix.tv/browse/pokemon-xyz"},
  89. {"name": "XY Kalos Quest",
  90. "link": "https://pokeflix.tv/browse/pokemon-xy-kalos-quest"},
  91. {"name": "XY",
  92. "link": "https://pokeflix.tv/browse/pokemon-xy"},
  93. ],
  94. },
  95. {"gen": "Generation 7 (Alola Region)",
  96. "seasons": [
  97. {"name": "Sun & Moon: Ultra Lengends",
  98. "link": "https://pokeflix.tv/browse/pokemon-sun-and-moon-ultra-legends"},
  99. {"name": "Sun & Moon: Ultra Adventures",
  100. "link": "https://pokeflix.tv/browse/pokemon-sun-and-moon-ultra-adventures"},
  101. {"name": "Sun & Moon",
  102. "link": "https://pokeflix.tv/browse/pokemon-sun-and-moon"},
  103. ],
  104. },
  105. {"gen": "Generation 8 (Galar Region)",
  106. "seasons": [
  107. {"name": "Journeys",
  108. "link": "https://pokeflix.py/browse/pokemon-journeys"}
  109. ],
  110. },
  111. ]
  112. for season in data[6]["seasons"]:
  113. print(season["name"])