Scraping the Russian-Kazakh translation website. Requires your terminal to work with UTF-8 symbols
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

29 righe
926 B

  1. from bs4 import BeautifulSoup
  2. import requests
  3. import sys, getopt
  4. import urllib.parse
  5. def main(argv):
  6. inputfile = ''
  7. inputfile = urllib.parse.quote(inputfile.encode('utf8'), ':/')
  8. numberfile = ''
  9. try:
  10. opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
  11. except getopt.GetoptError:
  12. print ('spotitube.py -i <Search Keyword> -o <Index>')
  13. sys.exit(2)
  14. for opt, arg in opts:
  15. if opt == '-h':
  16. print ('spotitube.py -i <Search Keyword> -o <Index>')
  17. sys.exit()
  18. elif opt in ("-i", "--ifile"):
  19. inputfile = arg
  20. elif opt in ("-o", "--ifile"):
  21. numberfile = arg
  22. html_content = requests.get(inputfile).text
  23. soup = BeautifulSoup(html_content, "lxml")
  24. print(soup.findAll("p",{"id":"dictionary_translate_article_translation"}))
  25. if __name__ == "__main__":
  26. main(sys.argv[1:])