parser01.py 855 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from bs4 import BeautifulSoup
  2. import requests
  3. import sys
  4. link_sp = []
  5. arg = sys.argv[1:]
  6. arg2 = arg[0].replace(" ", "+")
  7. print(arg2)
  8. x = 1
  9. while True:
  10. if x == 1:
  11. url = "https://filmot.com/search/" + str(arg2) + "/1/?"
  12. else:
  13. url = "https://filmot.com/search/" + str(arg2) + "/1/" + str(x) + "?"
  14. request = requests.get(url)
  15. soup = BeautifulSoup(request.text, "html.parser")
  16. teme = soup.find("div", {"id": "videoresults"})
  17. for temes in teme:
  18. temes = temes.find("img")
  19. if "https://img.youtube.com/" in str(temes):
  20. link = temes.get('src')
  21. it_link = "https://www.youtube.com/watch?v=" + str(link[27: 38])
  22. link_sp.append(it_link)
  23. x = x + 1
  24. if x == 4:
  25. break
  26. with open("link.txt", "w") as file:
  27. print(*link_sp, file=file, sep="\n")